iup-ffi 0.13.0-x86_64-linux
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.
- checksums.yaml +7 -0
- data/LICENCE.md +21 -0
- data/README.md +139 -0
- data/lib/iup-ffi-plain.rb +51 -0
- data/lib/iup-ffi.rb +70 -0
- data/lib/library/linux/libcd.so +0 -0
- data/lib/library/linux/libim.so +0 -0
- data/lib/library/linux/libiup.so +0 -0
- data/lib/library/linux/libiup_scintilla.so +0 -0
- data/lib/library/linux/libiupcd.so +0 -0
- data/lib/library/linux/libiupcontrols.so +0 -0
- data/lib/library/linux/libiupim.so +0 -0
- data/lib/library/linux/libiupimglib.so +0 -0
- data/lib/plain/iupcdlib.rb +158 -0
- data/lib/plain/iupcontrolslib.rb +28 -0
- data/lib/plain/iupimglib.rb +15 -0
- data/lib/plain/iupimlib.rb +18 -0
- data/lib/plain/iuplib.rb +354 -0
- data/lib/plain/scintilla-lib.rb +17 -0
- data/lib/wrapped/attribute-builders.rb +93 -0
- data/lib/wrapped/attribute-reference.rb +27 -0
- data/lib/wrapped/background-box.rb +37 -0
- data/lib/wrapped/button.rb +152 -0
- data/lib/wrapped/callback-setter.rb +78 -0
- data/lib/wrapped/canvas.rb +698 -0
- data/lib/wrapped/colorbar.rb +212 -0
- data/lib/wrapped/colordialog.rb +121 -0
- data/lib/wrapped/common-attributes.rb +34 -0
- data/lib/wrapped/constants.rb +504 -0
- data/lib/wrapped/dial.rb +129 -0
- data/lib/wrapped/dialog.rb +309 -0
- data/lib/wrapped/drag-drop-attributes.rb +98 -0
- data/lib/wrapped/dynamic-fill-methods.rb +22 -0
- data/lib/wrapped/expander.rb +128 -0
- data/lib/wrapped/filedialog.rb +168 -0
- data/lib/wrapped/fill.rb +29 -0
- data/lib/wrapped/fontdialog.rb +71 -0
- data/lib/wrapped/frame.rb +70 -0
- data/lib/wrapped/gridbox.rb +188 -0
- data/lib/wrapped/hbox.rb +90 -0
- data/lib/wrapped/image-attributes.rb +58 -0
- data/lib/wrapped/image.rb +178 -0
- data/lib/wrapped/iup-global.rb +46 -0
- data/lib/wrapped/label.rb +110 -0
- data/lib/wrapped/link.rb +54 -0
- data/lib/wrapped/list.rb +567 -0
- data/lib/wrapped/matrix.rb +575 -0
- data/lib/wrapped/menu.rb +91 -0
- data/lib/wrapped/menuitem.rb +150 -0
- data/lib/wrapped/messagedialog.rb +127 -0
- data/lib/wrapped/progressbar.rb +91 -0
- data/lib/wrapped/progressdialog.rb +85 -0
- data/lib/wrapped/radio.rb +74 -0
- data/lib/wrapped/scintilla.rb +1112 -0
- data/lib/wrapped/scrollbar-attributes.rb +178 -0
- data/lib/wrapped/scrollbox.rb +40 -0
- data/lib/wrapped/separator.rb +24 -0
- data/lib/wrapped/splitbox.rb +114 -0
- data/lib/wrapped/stretchbox.rb +70 -0
- data/lib/wrapped/submenu.rb +58 -0
- data/lib/wrapped/tabs.rb +223 -0
- data/lib/wrapped/text.rb +382 -0
- data/lib/wrapped/timer.rb +82 -0
- data/lib/wrapped/toggle.rb +150 -0
- data/lib/wrapped/tree.rb +612 -0
- data/lib/wrapped/val.rb +162 -0
- data/lib/wrapped/vbox.rb +93 -0
- data/lib/wrapped/widget.rb +282 -0
- data/lib/wrapped/zbox.rb +80 -0
- metadata +131 -0
data/lib/wrapped/tree.rb
ADDED
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# A tree displays a hierarchy of branch and leaf nodes.
|
|
4
|
+
# Each node may display some text and an optional image.
|
|
5
|
+
#
|
|
6
|
+
# === Example
|
|
7
|
+
#
|
|
8
|
+
# tree = Iup::Tree.new
|
|
9
|
+
#
|
|
10
|
+
# dlg = Iup::Dialog.new(tree) do |d|
|
|
11
|
+
# d.title = 'Tree Example'
|
|
12
|
+
# end.map
|
|
13
|
+
#
|
|
14
|
+
# tree.size = '80x80'
|
|
15
|
+
# tree.font = 'Courier, Normal 10'
|
|
16
|
+
# tree.addbranch(0, '3D')
|
|
17
|
+
# tree.addbranch(0, '2D')
|
|
18
|
+
# tree.addleaf(1, 'trapeze')
|
|
19
|
+
# tree.addbranch(1, 'parallelogram')
|
|
20
|
+
# tree.addleaf(2, 'diamond')
|
|
21
|
+
# tree.addleaf(2, 'square')
|
|
22
|
+
# tree.addbranch(4, 'triangle')
|
|
23
|
+
# tree.addleaf(5, 'scalenus')
|
|
24
|
+
# tree.addleaf(5, 'isoceles')
|
|
25
|
+
# tree.addleaf(5, 'equilateral')
|
|
26
|
+
# tree.value = 6
|
|
27
|
+
# tree.addexpanded = 'no'
|
|
28
|
+
#
|
|
29
|
+
# dlg.show
|
|
30
|
+
#
|
|
31
|
+
# Note: the contents of the tree can only be created after its containing
|
|
32
|
+
# dialog has been mapped.
|
|
33
|
+
#
|
|
34
|
+
class Tree < Iup::Widget
|
|
35
|
+
include DragDropAttributes
|
|
36
|
+
|
|
37
|
+
# Creates an instance of Tree.
|
|
38
|
+
# Unusually, does not accept an initialization block, as tree
|
|
39
|
+
# must be placed and mapped within a dialog before setup can
|
|
40
|
+
# take place - see Example.
|
|
41
|
+
def initialize
|
|
42
|
+
@handle = IupLib.IupTree
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# -- attributes
|
|
46
|
+
|
|
47
|
+
# --- general
|
|
48
|
+
|
|
49
|
+
##
|
|
50
|
+
# :attr: addexpanded
|
|
51
|
+
# 'yes' / 'no', to expand branches when created.
|
|
52
|
+
define_attribute :addexpanded
|
|
53
|
+
|
|
54
|
+
##
|
|
55
|
+
# :attr: addroot
|
|
56
|
+
# 'yes' / 'no', automatically adds an empty branch as the first node, on
|
|
57
|
+
# creation.
|
|
58
|
+
define_attribute :addroot
|
|
59
|
+
|
|
60
|
+
##
|
|
61
|
+
# :attr: canfocus
|
|
62
|
+
# Enables the control to gain focus. Values 'yes' / 'no'.
|
|
63
|
+
define_attribute :canfocus
|
|
64
|
+
|
|
65
|
+
##
|
|
66
|
+
# :attr_reader: count
|
|
67
|
+
# Returns total number of nodes in the tree.
|
|
68
|
+
define_reader :count
|
|
69
|
+
|
|
70
|
+
##
|
|
71
|
+
# :attr: dragdroptree
|
|
72
|
+
# Determines if tree supports dragdrop operations. Values 'yes' / 'no'.
|
|
73
|
+
define_attribute :dragdroptree
|
|
74
|
+
|
|
75
|
+
##
|
|
76
|
+
# :attr: dropequaldrag
|
|
77
|
+
# 'yes' / 'no', if set, allows a drop node to equal drag node.
|
|
78
|
+
define_attribute :dropequaldrag
|
|
79
|
+
|
|
80
|
+
##
|
|
81
|
+
# :attr: expand
|
|
82
|
+
# Allows control to fill available space in indicated direction.
|
|
83
|
+
# Values 'no' / 'horizontal' / 'vertical' / 'yes'.
|
|
84
|
+
define_attribute :expand
|
|
85
|
+
|
|
86
|
+
##
|
|
87
|
+
# :attr: hidebuttons
|
|
88
|
+
# 'yes' / 'no', to hide expand and create buttons.
|
|
89
|
+
define_attribute :hidebuttons
|
|
90
|
+
|
|
91
|
+
##
|
|
92
|
+
# :attr: hidelines
|
|
93
|
+
# 'yes' / 'no', the lines connecting nodes in hierarchy.
|
|
94
|
+
define_attribute :hidelines
|
|
95
|
+
|
|
96
|
+
##
|
|
97
|
+
# :attr: indentation
|
|
98
|
+
# level of indentation in pixels, defaults to 5.
|
|
99
|
+
define_attribute :indentation
|
|
100
|
+
|
|
101
|
+
##
|
|
102
|
+
# :attr_reader: position
|
|
103
|
+
# returns position in pixels within client window as "x,y".
|
|
104
|
+
define_reader :position
|
|
105
|
+
|
|
106
|
+
##
|
|
107
|
+
# :attr: rastersize
|
|
108
|
+
# Size of the control, in pixels, value as "widthxheight".
|
|
109
|
+
define_attribute :rastersize
|
|
110
|
+
|
|
111
|
+
##
|
|
112
|
+
# :attr_reader: screenposition
|
|
113
|
+
# returns position in pixels on screen as "x,y".
|
|
114
|
+
define_reader :screenposition
|
|
115
|
+
|
|
116
|
+
##
|
|
117
|
+
# :attr: showdragdrop
|
|
118
|
+
# 'yes' / 'no', enables internal drag and drop of nodes.
|
|
119
|
+
define_attribute :showdragdrop
|
|
120
|
+
|
|
121
|
+
##
|
|
122
|
+
# :attr: showtoggle
|
|
123
|
+
# 'yes' / 'no' / '3state', enables use of toggles for all nodes of the tree.
|
|
124
|
+
define_attribute :showtoggle
|
|
125
|
+
|
|
126
|
+
##
|
|
127
|
+
# :attr: spacing
|
|
128
|
+
# vertical, internal padding for each node, defaults to 3 pixels.
|
|
129
|
+
define_attribute :spacing
|
|
130
|
+
|
|
131
|
+
##
|
|
132
|
+
# :attr_writer: topitem
|
|
133
|
+
# Positions given node id at the top of tree, or near, to make it visible.
|
|
134
|
+
define_writer :topitem
|
|
135
|
+
|
|
136
|
+
##
|
|
137
|
+
# :attr:value
|
|
138
|
+
# When retrieved, returns the identifier of the focussed node. When
|
|
139
|
+
# given a value, moves focus appropriately:
|
|
140
|
+
# 'root' / 'last' / 'next' / 'previous' / 'pgdn' / 'pgup'
|
|
141
|
+
define_attribute :value
|
|
142
|
+
|
|
143
|
+
# --- nodes
|
|
144
|
+
|
|
145
|
+
# Returns the number of immediate child of given node.
|
|
146
|
+
# * +id+ - identifier of a node
|
|
147
|
+
def childcount id
|
|
148
|
+
IupLib.IupGetAttribute(@handle, "CHILDCOUNT#{id}").first
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# :call-seq:
|
|
152
|
+
# tree.color(id) # retrieves
|
|
153
|
+
# tree.color(id, val) # sets
|
|
154
|
+
#
|
|
155
|
+
# Accesses text foreground color:
|
|
156
|
+
# * +id+ - identifier of a node
|
|
157
|
+
# * +val+ - "r g b" color
|
|
158
|
+
def color id, val=nil
|
|
159
|
+
if val.nil?
|
|
160
|
+
IupLib.IupGetAttribute(@handle, "COLOR#{id}").first
|
|
161
|
+
else
|
|
162
|
+
IupLib.IupSetAttribute @handle, "COLOR#{id}", val
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Returns the depth of the given node.
|
|
167
|
+
# * +id+ - identifier of a node
|
|
168
|
+
def depth id
|
|
169
|
+
IupLib.IupGetAttribute(@handle, "DEPTH#{id}").first
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Returns kind of given node, as 'leaf' or 'branch'.
|
|
173
|
+
# * +id+ - identifier of a node
|
|
174
|
+
def kind id
|
|
175
|
+
IupLib.IupGetAttribute(@handle, "KIND#{id}").first
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Returns identifier of parent of given node.
|
|
179
|
+
# * +id+ - identifier of a node
|
|
180
|
+
def parent id
|
|
181
|
+
IupLib.IupGetAttribute(@handle, "PARENT#{id}").first
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# :call-seq:
|
|
185
|
+
# tree.state(id) # retrieves
|
|
186
|
+
# tree.state(id, val) # sets
|
|
187
|
+
#
|
|
188
|
+
# Accesses state as 'collapsed' or 'expanded':
|
|
189
|
+
# * +id+ - identifier of a node
|
|
190
|
+
# * +val+ - value 'collapsed' or 'expanded'.
|
|
191
|
+
def state id, val=nil
|
|
192
|
+
if val.nil?
|
|
193
|
+
IupLib.IupGetAttribute(@handle, "STATE#{id}").first
|
|
194
|
+
else
|
|
195
|
+
IupLib.IupSetAttribute @handle, "STATE#{id}", val
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# :call-seq:
|
|
200
|
+
# tree.title(id) # retrieves
|
|
201
|
+
# tree.title(id, val) # sets
|
|
202
|
+
#
|
|
203
|
+
# Accesses title of given node:
|
|
204
|
+
# * +id+ - identifier of a node
|
|
205
|
+
# * +val+ - title.
|
|
206
|
+
def title id, val=nil
|
|
207
|
+
if val.nil?
|
|
208
|
+
IupLib.IupGetAttribute(@handle, "TITLE#{id}").first
|
|
209
|
+
else
|
|
210
|
+
IupLib.IupSetAttribute @handle, "TITLE#{id}", val
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# :call-seq:
|
|
215
|
+
# tree.titlefont(id) # retrieves
|
|
216
|
+
# tree.titlefont(id, val) # sets
|
|
217
|
+
#
|
|
218
|
+
# Accesses font of node title:
|
|
219
|
+
# * +id+ - identifier of a node
|
|
220
|
+
# * +val+ - font description.
|
|
221
|
+
def titlefont id, val=nil
|
|
222
|
+
if val.nil?
|
|
223
|
+
IupLib.IupGetAttribute(@handle, "TITLEFONT#{id}").first
|
|
224
|
+
else
|
|
225
|
+
IupLib.IupSetAttribute @handle, "TITLEFONT#{id}", val
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
# :call-seq:
|
|
230
|
+
# tree.togglevalue(id) # retrieves
|
|
231
|
+
# tree.togglevalue(id, val) # sets
|
|
232
|
+
#
|
|
233
|
+
# Accesses toggle state of given node:
|
|
234
|
+
# * +id+ - identifier of a node
|
|
235
|
+
# * +val+ - state as 'on' / 'off' / 'notdef'
|
|
236
|
+
def togglevalue id, val=nil
|
|
237
|
+
if val.nil?
|
|
238
|
+
IupLib.IupGetAttribute(@handle, "TOGGLEVALUE#{id}").first
|
|
239
|
+
else
|
|
240
|
+
IupLib.IupSetAttribute @handle, "TOGGLEVALUE#{id}", val
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
# :call-seq:
|
|
245
|
+
# tree.togglevisible(id) # retrieves
|
|
246
|
+
# tree.togglevisible(id, val) # sets
|
|
247
|
+
#
|
|
248
|
+
# Accesses toggle visibility of given node:
|
|
249
|
+
# * +id+ - identifier of a node
|
|
250
|
+
# * +val+ - visibility as 'yes' / 'no'.
|
|
251
|
+
def togglevisible id, val=nil
|
|
252
|
+
if val.nil?
|
|
253
|
+
IupLib.IupGetAttribute(@handle, "TOGGLEVISIBLE#{id}").first
|
|
254
|
+
else
|
|
255
|
+
IupLib.IupSetAttribute @handle, "TOGGLEVISIBLE#{id}", val
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
# Returns total number of children for given node.
|
|
260
|
+
# * +id+ - identifier of a node
|
|
261
|
+
def totalchildcount id
|
|
262
|
+
IupLib.IupGetAttribute(@handle, "TOTALCHILDCOUNT#{id}").first
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
# :call-seq:
|
|
266
|
+
# tree.userdata(id) # retrieves
|
|
267
|
+
# tree.userdata(id, val) # sets
|
|
268
|
+
#
|
|
269
|
+
# Accesses userdata for given node id.
|
|
270
|
+
# * +id+ - identifier of a node
|
|
271
|
+
# * +val+ - user data (a string)
|
|
272
|
+
def userdata id, val=nil
|
|
273
|
+
if val.nil?
|
|
274
|
+
IupLib.IupGetAttribute(@handle, "USERDATA#{id}").first
|
|
275
|
+
else
|
|
276
|
+
IupLib.IupSetAttribute @handle, "USERDATA#{id}", val
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
# --- images
|
|
281
|
+
|
|
282
|
+
# Sets image to use for given node.
|
|
283
|
+
# * +id+ - identifier of a node
|
|
284
|
+
# * +img+ - image name or reference. This can use an actual image object, or the name of an image from +IupImageLib+.
|
|
285
|
+
def image id, img
|
|
286
|
+
attribute_reference "IMAGE#{id}", ImageWidget, img
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
# Sets image to use for given node, for expanded branches.
|
|
290
|
+
# * +id+ - identifier of a node
|
|
291
|
+
# * +img+ - image name or reference. This can use an actual image object, or the name of an image from +IupImageLib+.
|
|
292
|
+
def imageexpanded id, img
|
|
293
|
+
attribute_reference "IMAGEEXPANDED#{id}", ImageWidget, img
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
##
|
|
297
|
+
# :attr: imageleaf
|
|
298
|
+
# \Image to be used for all leaf nodes.
|
|
299
|
+
# This can use an actual image object, or the name of an image
|
|
300
|
+
# from +IupImageLib+.
|
|
301
|
+
|
|
302
|
+
# --
|
|
303
|
+
def imageleaf
|
|
304
|
+
attribute_reference("IMAGELEAF", ImageWidget, nil)
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
def imageleaf= img # :nodoc:
|
|
308
|
+
attribute_reference("IMAGELEAF", ImageWidget, img)
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
##
|
|
312
|
+
# :attr: imagebranchcollapsed
|
|
313
|
+
# \Image to be used for all collapsed branches.
|
|
314
|
+
# This can use an actual image object, or the name of an image
|
|
315
|
+
# from +IupImageLib+.
|
|
316
|
+
|
|
317
|
+
# --
|
|
318
|
+
def imagebranchcollapsed
|
|
319
|
+
attribute_reference("IMAGEBRANCHCOLLAPSED", ImageWidget, nil)
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
def imagebranchcollapsed= img # :nodoc:
|
|
323
|
+
attribute_reference("IMAGEBRANCHCOLLAPSED", ImageWidget, img)
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
##
|
|
327
|
+
# :attr: imagebranchexpanded
|
|
328
|
+
# \Image to be used for all expanded branches.
|
|
329
|
+
# This can use an actual image object, or the name of an image
|
|
330
|
+
# from +IupImageLib+.
|
|
331
|
+
|
|
332
|
+
# --
|
|
333
|
+
def imagebranchexpanded
|
|
334
|
+
attribute_reference("IMAGEBRANCHEXPANDED", ImageWidget, nil)
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
def imagebranchexpanded= img # :nodoc:
|
|
338
|
+
attribute_reference("IMAGEBRANCHEXPANDED", ImageWidget, img)
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
# --- marks
|
|
342
|
+
|
|
343
|
+
##
|
|
344
|
+
# :attr_writer: mark
|
|
345
|
+
# selects a range of nodes:
|
|
346
|
+
# 'start-end' / 'INVERTid' / 'block' / 'clearall' / 'markall' / 'invertall'
|
|
347
|
+
define_writer :mark
|
|
348
|
+
|
|
349
|
+
# :call-seq:
|
|
350
|
+
# tree.marked(id) # retrieves
|
|
351
|
+
# tree.marked(id, val) # sets
|
|
352
|
+
#
|
|
353
|
+
# Accesses marked state of node:
|
|
354
|
+
# * +id+ - identity of node
|
|
355
|
+
# * +val+ - 'yes' / 'no'
|
|
356
|
+
def marked id, val=nil
|
|
357
|
+
if val.nil?
|
|
358
|
+
IupLib.IupGetAttribute(@handle, "MARKED#{id}").first
|
|
359
|
+
else
|
|
360
|
+
IupLib.IupSetAttribute @handle, "MARKED#{id}", val
|
|
361
|
+
end
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
##
|
|
365
|
+
# :attr: markednodes
|
|
366
|
+
# Sets/gets selection indices of all marked nodes, when markmode=multiple.
|
|
367
|
+
|
|
368
|
+
# --
|
|
369
|
+
def markednodes
|
|
370
|
+
mns = IupLib.IupGetAttribute(@handle, 'MARKEDNODES').first
|
|
371
|
+
result = []
|
|
372
|
+
|
|
373
|
+
mns.split('').each_with_index do |item, index|
|
|
374
|
+
result << index+1 if item == '+'
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
return result
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
def markednodes= val # :nodoc:
|
|
381
|
+
result = ""
|
|
382
|
+
count.to_i.times do |i|
|
|
383
|
+
if val.include?(i+1)
|
|
384
|
+
result << '+'
|
|
385
|
+
else
|
|
386
|
+
result << '-'
|
|
387
|
+
end
|
|
388
|
+
end
|
|
389
|
+
IupLib.IupSetAttribute @handle, 'MARKEDNODES', result
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
##
|
|
393
|
+
# :attr: markmode
|
|
394
|
+
# 'single' / 'multiple', for selection of nodes.
|
|
395
|
+
define_attribute :markmode
|
|
396
|
+
|
|
397
|
+
##
|
|
398
|
+
# :attr: markstart
|
|
399
|
+
# Initial node for block marking, used when mark=block.
|
|
400
|
+
define_attribute :markstart
|
|
401
|
+
|
|
402
|
+
# --- hierarchy
|
|
403
|
+
|
|
404
|
+
# Adds new branch after specified node.
|
|
405
|
+
# * +id+ - identifier of a node
|
|
406
|
+
# * +val+ - text label
|
|
407
|
+
def addbranch id, val
|
|
408
|
+
IupLib.IupSetAttribute @handle, "ADDBRANCH#{id}", val.to_s
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
# Adds new leaf after specified node.
|
|
412
|
+
# * +id+ - identifier of a node
|
|
413
|
+
# * +val+ - text label
|
|
414
|
+
def addleaf id, val
|
|
415
|
+
IupLib.IupSetAttribute @handle, "ADDLEAF#{id}", val.to_s
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
# Copies source node and its children to target.
|
|
419
|
+
# * +source_id+ - identifier of a node
|
|
420
|
+
# * +target_id+ - identifier of a node
|
|
421
|
+
def copynode source_id, target_id
|
|
422
|
+
IupLib.IupSetAttribute @handle, "COPYNODE#{id}", target_id.to_s
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
# Delete one or more nodes:
|
|
426
|
+
# * +id+ - identifier of a node
|
|
427
|
+
# * +val+ - one of
|
|
428
|
+
# * 'all': ignores id and deletes all nodes in tree, including root.
|
|
429
|
+
# * 'selected': deletes selected node and its children.
|
|
430
|
+
# * 'children': deleted only the children of selected node.
|
|
431
|
+
# * 'marked': ignores id and deletes all selected node.
|
|
432
|
+
def delnode id, val
|
|
433
|
+
IupLib.IupSetAttribute @handle, "DELNODE#{id}", val.to_s
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
##
|
|
437
|
+
# :attr: expandall
|
|
438
|
+
# Expands or contracts all nodes, values 'yes' / 'no'.
|
|
439
|
+
define_attribute :expandall
|
|
440
|
+
|
|
441
|
+
# Inserts new branch after specified node, preserving depth.
|
|
442
|
+
# * +id+ - identifier of a node
|
|
443
|
+
# * +val+ - text label
|
|
444
|
+
def insertbranch id, val
|
|
445
|
+
IupLib.IupSetAttribute @handle, "INSERTBRANCH#{id}", val.to_s
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
# Inserts new leaf after specified node, preserving depth.
|
|
449
|
+
# * +id+ - identifier of a node
|
|
450
|
+
# * +val+ - text label
|
|
451
|
+
def insertleaf id, val
|
|
452
|
+
IupLib.IupSetAttribute @handle, "INSERTLEAF#{id}", val.to_s
|
|
453
|
+
end
|
|
454
|
+
|
|
455
|
+
# Moves source to target, as a new child or sibling.
|
|
456
|
+
# * +source_id+ - identifier of a node
|
|
457
|
+
# * +target_id+ - identifier of a node
|
|
458
|
+
def movenode source_id, target_id
|
|
459
|
+
IupLib.IupSetAttribute @handle, "MOVENODE#{id}", target_id.to_s
|
|
460
|
+
end
|
|
461
|
+
|
|
462
|
+
# :section: Callbacks
|
|
463
|
+
|
|
464
|
+
##
|
|
465
|
+
# :attr_writer: selection_cb
|
|
466
|
+
# Callback called when a node is selected or deselected.
|
|
467
|
+
# Callback must respond to +call+ and takes 2 arguments: (node_id, status)
|
|
468
|
+
# * +node_id+ - reference to node
|
|
469
|
+
# * +status+ - whether node is selected or deselected
|
|
470
|
+
|
|
471
|
+
# --
|
|
472
|
+
def selection_cb= callback
|
|
473
|
+
unless callback.arity == 2
|
|
474
|
+
raise ArgumentError, 'selection_cb callback must take 2 arguments: node_id, status'
|
|
475
|
+
end
|
|
476
|
+
cb = Proc.new do |ih, id, status|
|
|
477
|
+
callback.call id, status
|
|
478
|
+
end
|
|
479
|
+
define_callback cb, 'SELECTION_CB', :ii_i
|
|
480
|
+
end
|
|
481
|
+
|
|
482
|
+
##
|
|
483
|
+
# :attr_writer: branchopen_cb
|
|
484
|
+
# Callback called when a branch is expanded.
|
|
485
|
+
# Callback must respond to +call+ and takes 1 argument: (node_id)
|
|
486
|
+
# * +node_id+ - reference to node opened
|
|
487
|
+
|
|
488
|
+
# --
|
|
489
|
+
def branchopen_cb= callback
|
|
490
|
+
unless callback.arity == 1
|
|
491
|
+
raise ArgumentError, 'branchopen_cb callback must take 1 argument: node_id'
|
|
492
|
+
end
|
|
493
|
+
cb = Proc.new do |ih, id|
|
|
494
|
+
callback.call id
|
|
495
|
+
end
|
|
496
|
+
define_callback cb, 'BRANCHOPEN_CB', :i_i
|
|
497
|
+
end
|
|
498
|
+
|
|
499
|
+
##
|
|
500
|
+
# :attr_writer: branchclose_cb
|
|
501
|
+
# Callback called when a branch is collapsed.
|
|
502
|
+
# Callback must respond to +call+ and takes 1 argument: (node_id)
|
|
503
|
+
# * +node_id+ - reference to node closed
|
|
504
|
+
|
|
505
|
+
# --
|
|
506
|
+
def branchclose_cb= callback
|
|
507
|
+
unless callback.arity == 1
|
|
508
|
+
raise ArgumentError, 'branchclose_cb callback must take 1 argument: node_id'
|
|
509
|
+
end
|
|
510
|
+
cb = Proc.new do |ih, id|
|
|
511
|
+
callback.call id
|
|
512
|
+
end
|
|
513
|
+
define_callback cb, 'BRANCHCLOSE_CB', :i_i
|
|
514
|
+
end
|
|
515
|
+
|
|
516
|
+
##
|
|
517
|
+
# :attr_writer: executeleaf_cb
|
|
518
|
+
# Callback called when a leaf is to be executed.
|
|
519
|
+
# Callback must respond to +call+ and takes 1 argument: (node_id)
|
|
520
|
+
# * +node_id+ - reference to node
|
|
521
|
+
|
|
522
|
+
# --
|
|
523
|
+
def executeleaf_cb= callback
|
|
524
|
+
unless callback.arity == 1
|
|
525
|
+
raise ArgumentError, 'executeleaf_cb callback must take 1 argument: node_id'
|
|
526
|
+
end
|
|
527
|
+
cb = Proc.new do |ih, id|
|
|
528
|
+
callback.call id
|
|
529
|
+
end
|
|
530
|
+
define_callback cb, 'EXECUTELEAF_CB', :i_i
|
|
531
|
+
end
|
|
532
|
+
|
|
533
|
+
##
|
|
534
|
+
# :attr_writer: rightclick_cb
|
|
535
|
+
# Callback called when the right mouse button is pressed over a node.
|
|
536
|
+
# Callback must respond to +call+ and takes 1 argument: (node_id)
|
|
537
|
+
# * +node_id+ - reference to node
|
|
538
|
+
|
|
539
|
+
# --
|
|
540
|
+
def rightclick_cb= callback
|
|
541
|
+
unless callback.arity == 1
|
|
542
|
+
raise ArgumentError, 'rightclick_cb callback must take 1 argument: node_id'
|
|
543
|
+
end
|
|
544
|
+
cb = Proc.new do |ih, id|
|
|
545
|
+
callback.call id
|
|
546
|
+
end
|
|
547
|
+
define_callback cb, 'RIGHTCLICK_CB', :i_i
|
|
548
|
+
end
|
|
549
|
+
|
|
550
|
+
##
|
|
551
|
+
# :attr_writer: togglevalue_cb
|
|
552
|
+
# Callback called when the toggle's state was changed.
|
|
553
|
+
# Callback must respond to +call+ and takes 2 arguments: (node_id, status).
|
|
554
|
+
# * +node_id+ - reference to node
|
|
555
|
+
# * +status+ - new state of toggle
|
|
556
|
+
|
|
557
|
+
# --
|
|
558
|
+
def togglevalue_cb= callback
|
|
559
|
+
unless callback.arity == 2
|
|
560
|
+
raise ArgumentError, 'togglevalue_cb callback must take 2 arguments: node_id, status'
|
|
561
|
+
end
|
|
562
|
+
cb = Proc.new do |ih, id, status|
|
|
563
|
+
callback.call id, status
|
|
564
|
+
end
|
|
565
|
+
define_callback cb, 'TOGGLEVALUE_CB', :ii_i
|
|
566
|
+
end
|
|
567
|
+
|
|
568
|
+
include ButtonCallback
|
|
569
|
+
|
|
570
|
+
##
|
|
571
|
+
# :attr_writer: dragdrop_cb
|
|
572
|
+
# Callback called when an internal drag & drop is executed. Only active if
|
|
573
|
+
# SHOWDRAGDROP=YES.
|
|
574
|
+
# Callback must respond to +call+ and accepts 4 arguments (drag_id,
|
|
575
|
+
# drop_id, isshift, iscontrol)
|
|
576
|
+
# * +drag_id+ - is an integer index of dragged item
|
|
577
|
+
# * +drop_id+ - is an integer index of drop location
|
|
578
|
+
# * +isshift+ - boolean flag for if shift key held
|
|
579
|
+
# * +iscontrol+ - boolean flag for if control key held
|
|
580
|
+
# Callback should return Iup::CONTINUE for item to be moved/copied.
|
|
581
|
+
|
|
582
|
+
# --
|
|
583
|
+
def dragdrop_cb= callback
|
|
584
|
+
unless callback.arity == 4
|
|
585
|
+
raise ArgumentError, 'dragdrop_cb callback must take 4 arguments: (drag_id, drop_id, isshift, iscontrol)'
|
|
586
|
+
end
|
|
587
|
+
cb = Proc.new do |ih, drag_id, drop_id, isshift, iscontrol|
|
|
588
|
+
callback.call drag_id.to_i, drop_id.to_i, (isshift != 0), (iscontrol != 0)
|
|
589
|
+
end
|
|
590
|
+
define_callback cb, 'DRAGDROP_CB', :iiii_i
|
|
591
|
+
end
|
|
592
|
+
|
|
593
|
+
##
|
|
594
|
+
# :attr_writer: motion_cb
|
|
595
|
+
# Callback called when the mouse is moved.
|
|
596
|
+
# Callback must respond to +call+ and takes 3 arguments: (x, y, state)
|
|
597
|
+
# * +x+ - x position of mouse
|
|
598
|
+
# * +y+ - y position of mouse
|
|
599
|
+
# * +state+ - status of mouse buttons and certain keyboard keys at the moment the event was generated.
|
|
600
|
+
|
|
601
|
+
#--
|
|
602
|
+
def motion_cb= callback
|
|
603
|
+
unless callback.arity == 3
|
|
604
|
+
raise ArgumentError, 'motion_cb callback must take 3 arguments: (x, y, state)'
|
|
605
|
+
end
|
|
606
|
+
cb = Proc.new do |ih, x, y, state|
|
|
607
|
+
callback.call x, y, state
|
|
608
|
+
end
|
|
609
|
+
define_callback cb, 'MOTION_CB', :iis_i
|
|
610
|
+
end
|
|
611
|
+
end
|
|
612
|
+
end
|