iup-ffi 0.12.0
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.txt +21 -0
- data/README.rdoc +348 -0
- data/lib/iup-ffi-plain.rb +9 -0
- data/lib/iup-ffi.rb +76 -0
- data/lib/plain/iupcdlib.rb +107 -0
- data/lib/plain/iupcontrolslib.rb +24 -0
- data/lib/plain/iupimglib.rb +14 -0
- data/lib/plain/iupimlib.rb +16 -0
- data/lib/plain/iuplib.rb +209 -0
- data/lib/plain/scintilla-lib.rb +15 -0
- data/lib/wrapped/attribute-builders.rb +105 -0
- data/lib/wrapped/attribute-reference.rb +27 -0
- data/lib/wrapped/background-box.rb +33 -0
- data/lib/wrapped/button.rb +108 -0
- data/lib/wrapped/callback-setter.rb +78 -0
- data/lib/wrapped/canvas.rb +467 -0
- data/lib/wrapped/colourbar.rb +94 -0
- data/lib/wrapped/colourdialog.rb +63 -0
- data/lib/wrapped/common-attributes.rb +64 -0
- data/lib/wrapped/constants.rb +953 -0
- data/lib/wrapped/dial.rb +87 -0
- data/lib/wrapped/dialog.rb +176 -0
- data/lib/wrapped/dialogs.rb +106 -0
- data/lib/wrapped/drag-drop-attributes.rb +57 -0
- data/lib/wrapped/dynamic-fill-methods.rb +27 -0
- data/lib/wrapped/expander.rb +65 -0
- data/lib/wrapped/filedialog.rb +93 -0
- data/lib/wrapped/fill.rb +26 -0
- data/lib/wrapped/fontdialog.rb +42 -0
- data/lib/wrapped/frame.rb +47 -0
- data/lib/wrapped/gridbox.rb +94 -0
- data/lib/wrapped/hbox.rb +49 -0
- data/lib/wrapped/image-attributes.rb +27 -0
- data/lib/wrapped/image.rb +118 -0
- data/lib/wrapped/internal-drag-drop-attributes.rb +21 -0
- data/lib/wrapped/iup-global.rb +51 -0
- data/lib/wrapped/label.rb +98 -0
- data/lib/wrapped/link.rb +59 -0
- data/lib/wrapped/list.rb +353 -0
- data/lib/wrapped/matrix.rb +233 -0
- data/lib/wrapped/menu.rb +50 -0
- data/lib/wrapped/menuitem.rb +80 -0
- data/lib/wrapped/messagedialog.rb +51 -0
- data/lib/wrapped/progressbar.rb +48 -0
- data/lib/wrapped/progressdialog.rb +111 -0
- data/lib/wrapped/radio.rb +43 -0
- data/lib/wrapped/scintilla.rb +277 -0
- data/lib/wrapped/scrollbar-attributes.rb +141 -0
- data/lib/wrapped/scrollbox.rb +147 -0
- data/lib/wrapped/separator.rb +11 -0
- data/lib/wrapped/splitbox.rb +48 -0
- data/lib/wrapped/stretchbox.rb +42 -0
- data/lib/wrapped/submenu.rb +34 -0
- data/lib/wrapped/tabs.rb +149 -0
- data/lib/wrapped/text.rb +225 -0
- data/lib/wrapped/timer.rb +42 -0
- data/lib/wrapped/toggle.rb +98 -0
- data/lib/wrapped/tree.rb +465 -0
- data/lib/wrapped/val.rb +97 -0
- data/lib/wrapped/vbox.rb +51 -0
- data/lib/wrapped/widget.rb +137 -0
- data/lib/wrapped/zbox.rb +54 -0
- metadata +124 -0
data/lib/wrapped/tree.rb
ADDED
|
@@ -0,0 +1,465 @@
|
|
|
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
|
+
# The contents of the tree can _only_ be created after the tree has been
|
|
7
|
+
# located in a dialog, and before the Dialog#show method is called.
|
|
8
|
+
# See the example below:
|
|
9
|
+
#
|
|
10
|
+
# mainloop do
|
|
11
|
+
#
|
|
12
|
+
# tree = Tree.new
|
|
13
|
+
#
|
|
14
|
+
# dlg = Dialog.new tree do
|
|
15
|
+
# title 'Tree Example'
|
|
16
|
+
# end.map
|
|
17
|
+
#
|
|
18
|
+
# tree.instance_eval do
|
|
19
|
+
# title 'Figures'
|
|
20
|
+
# size '80x80'
|
|
21
|
+
# font 'Courier, Normal 10'
|
|
22
|
+
# title 'Figures'
|
|
23
|
+
# addbranch 0, '3D'
|
|
24
|
+
# addbranch 0, '2D'
|
|
25
|
+
# addleaf 1, 'trapeze'
|
|
26
|
+
# addbranch 1, 'parallelogram'
|
|
27
|
+
# addleaf 2, 'diamond'
|
|
28
|
+
# addleaf 2, 'square'
|
|
29
|
+
# addbranch 4, 'triangle'
|
|
30
|
+
# addleaf 5, 'scalenus'
|
|
31
|
+
# addleaf 5, 'isoceles'
|
|
32
|
+
# addleaf 5, 'equilateral'
|
|
33
|
+
# value 6
|
|
34
|
+
# addexpanded 'no'
|
|
35
|
+
# end
|
|
36
|
+
#
|
|
37
|
+
# dlg.show
|
|
38
|
+
# end
|
|
39
|
+
#
|
|
40
|
+
# == Attributes
|
|
41
|
+
#
|
|
42
|
+
# addexpanded:: 'yes' / 'no', to expand branches when created.
|
|
43
|
+
# addroot:: 'yes' / 'no', automatically adds an empty branch as
|
|
44
|
+
# the first node, on creation.
|
|
45
|
+
# canfocus:: Enables the control to gain focus. Values 'yes' / 'no'.
|
|
46
|
+
# count:: <b>read-only</b> returns total number of nodes in the tree.
|
|
47
|
+
# dragdroptree:: 'yes' / 'no'.
|
|
48
|
+
# dropequaldrag:: 'yes' / 'no', if set, allows a drop node to equal drag node.
|
|
49
|
+
# expand:: Allows control to fill available space in indicated direction.
|
|
50
|
+
# Values 'no' / 'horizontal' / 'vertical' / 'yes'.
|
|
51
|
+
# hidebuttons:: 'yes' / 'no', to hide expand and create buttons.
|
|
52
|
+
# hidelines:: 'yes' / 'no', the lines connecting nodes in hierarchy.
|
|
53
|
+
# indentation:: level of indentation in pixels, defaults to 5.
|
|
54
|
+
# position:: <b>read-only</b> returns position in pixels within client window
|
|
55
|
+
# as "x,y".
|
|
56
|
+
# rastersize:: Size of the control, in pixels, value as "widthxheight".
|
|
57
|
+
# screenposition:: <b>read-only</b> returns position in pixels on screen
|
|
58
|
+
# as "x,y".
|
|
59
|
+
# showdragdrop:: 'yes' / 'no', enables internal drag and drop of nodes.
|
|
60
|
+
# showtoggle:: 'yes' / 'no' / '3state', enables use of toggles for all nodes of the tree.
|
|
61
|
+
# spacing:: vertical, internal padding for each node, defaults to 3 pixels.
|
|
62
|
+
# topitem:: <b>write-only</b> Positions given node id at the top of tree,
|
|
63
|
+
# or near, to make it visible.
|
|
64
|
+
# value:: When retrieved, returns the identifier of the focussed node. When
|
|
65
|
+
# given a value, moves focus appropriately:
|
|
66
|
+
# 'root' / 'last' / 'next' / 'previous' / 'pgdn' / 'pgup'
|
|
67
|
+
#
|
|
68
|
+
# mark:: <b>write-only> selects a range of nodes:
|
|
69
|
+
# 'start-end' / 'INVERTid' / 'block' / 'clearall' / 'markall' / 'invertall'
|
|
70
|
+
# markmode:: 'single' / 'multiple', for selection of nodes.
|
|
71
|
+
# markstart:: Initial node for block marking, used when mark=block.
|
|
72
|
+
#
|
|
73
|
+
# expandall:: Expands or contracts all nodes, values 'yes' / 'no'.
|
|
74
|
+
#
|
|
75
|
+
class Tree < Widget
|
|
76
|
+
include DragDropAttributes
|
|
77
|
+
|
|
78
|
+
# Creates an instance of Tree which is set up via the _block_.
|
|
79
|
+
def initialize &block
|
|
80
|
+
@handle = IupLib.IupTree
|
|
81
|
+
|
|
82
|
+
# run any provided block on instance, to set up further attributes
|
|
83
|
+
self.instance_eval &block if block_given?
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# -- attributes
|
|
87
|
+
|
|
88
|
+
# --- general
|
|
89
|
+
define_attribute :addexpanded
|
|
90
|
+
define_attribute :addroot
|
|
91
|
+
define_attribute :canfocus
|
|
92
|
+
define_readonly :count
|
|
93
|
+
define_attribute :dragdroptree
|
|
94
|
+
define_attribute :dropequaldrag
|
|
95
|
+
define_attribute :expand
|
|
96
|
+
define_attribute :hidebuttons
|
|
97
|
+
define_attribute :hidelines
|
|
98
|
+
define_attribute :indentation
|
|
99
|
+
define_readonly :position
|
|
100
|
+
define_attribute :rastersize
|
|
101
|
+
define_readonly :screenposition
|
|
102
|
+
define_attribute :showdragdrop
|
|
103
|
+
define_attribute :showtoggle
|
|
104
|
+
define_attribute :spacing
|
|
105
|
+
define_attribute :topitem
|
|
106
|
+
define_attribute :value
|
|
107
|
+
|
|
108
|
+
# --- nodes
|
|
109
|
+
|
|
110
|
+
# Returns the number of immediate child of given node.
|
|
111
|
+
# id:: identifier of a node
|
|
112
|
+
def childcount id
|
|
113
|
+
IupLib.IupGetAttribute(@handle, "CHILDCOUNT#{id}").first
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Controls text foreground colour:
|
|
117
|
+
# provide a 'val' to set colour, otherwise, current colour returned.
|
|
118
|
+
# id:: identifier of a node
|
|
119
|
+
# val:: optional "r g b" colour
|
|
120
|
+
def color id, val=nil
|
|
121
|
+
if val.nil?
|
|
122
|
+
IupLib.IupGetAttribute(@handle, "COLOR#{id}").first
|
|
123
|
+
else
|
|
124
|
+
IupLib.IupSetAttribute @handle, "COLOR#{id}", val
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Returns the depth of the given node.
|
|
129
|
+
# id:: identifier of a node
|
|
130
|
+
def depth id
|
|
131
|
+
IupLib.IupGetAttribute(@handle, "DEPTH#{id}").first
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Returns kind of given node, as 'leaf' or 'branch'.
|
|
135
|
+
# id:: identifier of a node
|
|
136
|
+
def kind id
|
|
137
|
+
IupLib.IupGetAttribute(@handle, "KIND#{id}").first
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Returns identifier of parent of given node.
|
|
141
|
+
# id:: identifier of a node
|
|
142
|
+
def parent id
|
|
143
|
+
IupLib.IupGetAttribute(@handle, "PARENT#{id}").first
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Controls state as 'collapsed' or 'expanded':
|
|
147
|
+
# provide a 'val' to set state, otherwise, current state returned (nil for a leaf).
|
|
148
|
+
# id:: identifier of a node
|
|
149
|
+
# val:: optional value 'collapsed' or 'expanded'.
|
|
150
|
+
def state id, val=nil
|
|
151
|
+
if val.nil?
|
|
152
|
+
IupLib.IupGetAttribute(@handle, "STATE#{id}").first
|
|
153
|
+
else
|
|
154
|
+
IupLib.IupSetAttribute @handle, "STATE#{id}", val
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Controls title of given node:
|
|
159
|
+
# provide a 'val' to set, otherwise, current title returned.
|
|
160
|
+
# id:: identifier of a node
|
|
161
|
+
# val:: optional title.
|
|
162
|
+
def title id, val=nil
|
|
163
|
+
if val.nil?
|
|
164
|
+
IupLib.IupGetAttribute(@handle, "TITLE#{id}").first
|
|
165
|
+
else
|
|
166
|
+
IupLib.IupSetAttribute @handle, "TITLE#{id}", val
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Controls font of node title:
|
|
171
|
+
# provide a 'val' to set font, otherwise, current font returned.
|
|
172
|
+
# id:: identifier of a node
|
|
173
|
+
# val:: optional font description.
|
|
174
|
+
def titlefont id, val=nil
|
|
175
|
+
if val.nil?
|
|
176
|
+
IupLib.IupGetAttribute(@handle, "TITLEFONT#{id}").first
|
|
177
|
+
else
|
|
178
|
+
IupLib.IupSetAttribute @handle, "TITLEFONT#{id}", val
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# Controls toggle state of given node:
|
|
183
|
+
# provide a 'val' to set state, otherwise, current state returned.
|
|
184
|
+
# id:: identifier of a node
|
|
185
|
+
# val:: optional state as 'on' / 'off' / 'notdef'
|
|
186
|
+
def togglevalue id, val=nil
|
|
187
|
+
if val.nil?
|
|
188
|
+
IupLib.IupGetAttribute(@handle, "TOGGLEVALUE#{id}").first
|
|
189
|
+
else
|
|
190
|
+
IupLib.IupSetAttribute @handle, "TOGGLEVALUE#{id}", val
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# Controls toggle visibility of given node:
|
|
195
|
+
# provide a 'val' to set visibility, otherwise, current visibility returned.
|
|
196
|
+
# id:: identifier of a node
|
|
197
|
+
# val:: optional visibility as 'yes' / 'no'.
|
|
198
|
+
def togglevisible id, val=nil
|
|
199
|
+
if val.nil?
|
|
200
|
+
IupLib.IupGetAttribute(@handle, "TOGGLEVISIBLE#{id}").first
|
|
201
|
+
else
|
|
202
|
+
IupLib.IupSetAttribute @handle, "TOGGLEVISIBLE#{id}", val
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Returns total number of children for given node.
|
|
207
|
+
# id:: identifier of a node
|
|
208
|
+
def totalchildcount id
|
|
209
|
+
IupLib.IupGetAttribute(@handle, "TOTALCHILDCOUNT#{id}").first
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# Controls user data associated with given node:
|
|
213
|
+
# provide a 'val' to set userdata, otherwise, current userdata returned.
|
|
214
|
+
# id:: identifier of a node
|
|
215
|
+
# val:: optional userdata to associate with given node.
|
|
216
|
+
def userdata id, val=nil
|
|
217
|
+
if val.nil?
|
|
218
|
+
IupLib.IupGetAttribute(@handle, "USERDATA#{id}").first
|
|
219
|
+
else
|
|
220
|
+
IupLib.IupSetAttribute @handle, "USERDATA#{id}", val
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
# --- images
|
|
225
|
+
|
|
226
|
+
# Sets image to use for given node.
|
|
227
|
+
# id:: identifier of a node
|
|
228
|
+
# img:: image name or reference
|
|
229
|
+
def image id, img
|
|
230
|
+
attribute_reference "IMAGE#{id}", ImageWidget, img
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Sets image to use for given node, for expanded branches.
|
|
234
|
+
# id:: identifier of a node
|
|
235
|
+
# img:: image name or reference
|
|
236
|
+
def imageexpanded id, img
|
|
237
|
+
attribute_reference "IMAGEEXPANDED#{id}", ImageWidget, img
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
# If given, sets image to be used for all leaf nodes,
|
|
241
|
+
# otherwise returns current value.
|
|
242
|
+
# img:: optional image name or reference
|
|
243
|
+
def imageleaf img=nil
|
|
244
|
+
attribute_reference "IMAGELEAF", ImageWidget, img
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
# If given, sets image to be used for all collapsed branches,
|
|
248
|
+
# otherwise returns current value.
|
|
249
|
+
# img:: optional image name or reference
|
|
250
|
+
def imagebranchcollapsed img=nil
|
|
251
|
+
attribute_reference "IMAGEBRANCHCOLLAPSED", ImageWidget, img
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
# If given, sets image to be used for all expanded branches,
|
|
255
|
+
# otherwise returns current value.
|
|
256
|
+
# img:: optional image name or reference
|
|
257
|
+
def imagebranchexpanded img=nil
|
|
258
|
+
attribute_reference "IMAGEBRANCHEXPANDED", ImageWidget, img
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
# --- marks
|
|
262
|
+
define_writeonly :mark
|
|
263
|
+
|
|
264
|
+
# Selection state of specific node returned or, if val given, set.
|
|
265
|
+
# id:: identifier of a node
|
|
266
|
+
# val:: optional 'yes' / 'no'
|
|
267
|
+
def marked id, val=nil
|
|
268
|
+
if val.nil?
|
|
269
|
+
IupLib.IupGetAttribute(@handle, "MARKED#{id}").first
|
|
270
|
+
else
|
|
271
|
+
IupLib.IupSetAttribute @handle, "MARKED#{id}", val
|
|
272
|
+
end
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
# Sets/gets selection indices of all marked nodes, when
|
|
276
|
+
# markmode=multiple.
|
|
277
|
+
# val:: optional [ids]
|
|
278
|
+
def markednodes val=nil
|
|
279
|
+
if val.nil?
|
|
280
|
+
mns = IupLib.IupGetAttribute(@handle, 'MARKEDNODES').first
|
|
281
|
+
result = []
|
|
282
|
+
mns.split('').each_with_index do |item, index|
|
|
283
|
+
result << index+1 if item == '+'
|
|
284
|
+
end
|
|
285
|
+
return result
|
|
286
|
+
else
|
|
287
|
+
result = ""
|
|
288
|
+
count.to_i.times do |i|
|
|
289
|
+
if val.include?(i+1)
|
|
290
|
+
result << '+'
|
|
291
|
+
else
|
|
292
|
+
result << '-'
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
IupLib.IupSetAttribute @handle, 'MARKEDNODES', result
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
define_attribute :markmode
|
|
300
|
+
define_attribute :markstart
|
|
301
|
+
|
|
302
|
+
# --- hierarchy
|
|
303
|
+
|
|
304
|
+
# Adds new branch after specified node.
|
|
305
|
+
# id:: identifier of a node
|
|
306
|
+
# val:: text label
|
|
307
|
+
def addbranch id, val
|
|
308
|
+
IupLib.IupSetAttribute @handle, "ADDBRANCH#{id}", val.to_s
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
# Adds new leaf after specified node.
|
|
312
|
+
# id:: identifier of a node
|
|
313
|
+
# val:: text label
|
|
314
|
+
def addleaf id, val
|
|
315
|
+
IupLib.IupSetAttribute @handle, "ADDLEAF#{id}", val.to_s
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
# Copies source node and its children to target.
|
|
319
|
+
# source_id:: identifier of a node
|
|
320
|
+
# target_id:: identifier of a node
|
|
321
|
+
def copynode source_id, target_id
|
|
322
|
+
IupLib.IupSetAttribute @handle, "COPYNODE#{id}", target_id.to_s
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
# Delete one or more nodes, depending on val:
|
|
326
|
+
# * 'all': ignores id and deletes all nodes in tree, including root.
|
|
327
|
+
# * 'selected': deletes selected node and its children.
|
|
328
|
+
# * 'children': deleted only the children of selected node.
|
|
329
|
+
# * 'marked': ignores id and deletes all selected node.
|
|
330
|
+
#
|
|
331
|
+
# id:: identifier of a node
|
|
332
|
+
# val:: one of above values
|
|
333
|
+
def delnode id, val
|
|
334
|
+
IupLib.IupSetAttribute @handle, "DELNODE#{id}", val.to_s
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
define_attribute :expandall
|
|
338
|
+
|
|
339
|
+
# Inserts new branch after specified node, preserving depth.
|
|
340
|
+
# id:: identifier of a node
|
|
341
|
+
# val:: text label
|
|
342
|
+
def insertbranch id, val
|
|
343
|
+
IupLib.IupSetAttribute @handle, "INSERTBRANCH#{id}", val.to_s
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
# Inserts new leaf after specified node, preserving depth.
|
|
347
|
+
# id:: identifier of a node
|
|
348
|
+
# val:: text label
|
|
349
|
+
def insertleaf id, val
|
|
350
|
+
IupLib.IupSetAttribute @handle, "INSERTLEAF#{id}", val.to_s
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
# Moves source to target, as a new child or sibling.
|
|
354
|
+
# source_id:: identifier of a node
|
|
355
|
+
# target_id:: identifier of a node
|
|
356
|
+
def movenode source_id, target_id
|
|
357
|
+
IupLib.IupSetAttribute @handle, "MOVENODE#{id}", target_id.to_s
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# -- callbacks
|
|
361
|
+
|
|
362
|
+
# Action generated when a node is selected or deselected.
|
|
363
|
+
def selection_cb callback
|
|
364
|
+
unless callback.arity == 2
|
|
365
|
+
raise ArgumentError, 'selection_cb callback must take 2 arguments: node_id, status'
|
|
366
|
+
end
|
|
367
|
+
cb = Proc.new do |ih, id, status|
|
|
368
|
+
callback.call id, status
|
|
369
|
+
end
|
|
370
|
+
define_callback cb, 'SELECTION_CB', :ii_i
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
# Action generated when a branch is expanded.
|
|
374
|
+
def branchopen_cb callback
|
|
375
|
+
unless callback.arity == 1
|
|
376
|
+
raise ArgumentError, 'branchopen_cb callback must take 1 argument: node_id'
|
|
377
|
+
end
|
|
378
|
+
cb = Proc.new do |ih, id|
|
|
379
|
+
callback.call id
|
|
380
|
+
end
|
|
381
|
+
define_callback cb, 'BRANCHOPEN_CB', :i_i
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
# ction generated when a branch is collapsed.
|
|
385
|
+
def branchclose_cb callback
|
|
386
|
+
unless callback.arity == 1
|
|
387
|
+
raise ArgumentError, 'branchclose_cb callback must take 1 argument: node_id'
|
|
388
|
+
end
|
|
389
|
+
cb = Proc.new do |ih, id|
|
|
390
|
+
callback.call id
|
|
391
|
+
end
|
|
392
|
+
define_callback cb, 'BRANCHCLOSE_CB', :i_i
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
# Action generated when a leaf is to be executed
|
|
396
|
+
def executeleaf_cb callback
|
|
397
|
+
unless callback.arity == 1
|
|
398
|
+
raise ArgumentError, 'executeleaf_cb callback must take 1 argument: node_id'
|
|
399
|
+
end
|
|
400
|
+
cb = Proc.new do |ih, id|
|
|
401
|
+
callback.call id
|
|
402
|
+
end
|
|
403
|
+
define_callback cb, 'EXECUTELEAF_CB', :i_i
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
# Action generated when the right mouse button is pressed over a node.
|
|
407
|
+
def rightclick_cb callback
|
|
408
|
+
unless callback.arity == 1
|
|
409
|
+
raise ArgumentError, 'rightclick_cb callback must take 1 argument: node_id'
|
|
410
|
+
end
|
|
411
|
+
cb = Proc.new do |ih, id|
|
|
412
|
+
callback.call id
|
|
413
|
+
end
|
|
414
|
+
define_callback cb, 'RIGHTCLICK_CB', :i_i
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
# Action generated when the toggle's state was changed.
|
|
418
|
+
def togglevalue_cb callback
|
|
419
|
+
unless callback.arity == 2
|
|
420
|
+
raise ArgumentError, 'togglevalue_cb callback must take 2 arguments: node_id, status'
|
|
421
|
+
end
|
|
422
|
+
cb = Proc.new do |ih, id, status|
|
|
423
|
+
callback.call id, status
|
|
424
|
+
end
|
|
425
|
+
define_callback cb, 'TOGGLEVALUE_CB', :ii_i
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
include ButtonCallback
|
|
429
|
+
|
|
430
|
+
# Action generated when an internal drag & drop is executed. Only active if SHOWDRAGDROP=YES.
|
|
431
|
+
# dragdrop_cb takes a callback which accepts 4 arguments (drag_id, drop_id, isshift, iscontrol)
|
|
432
|
+
# drag_id:: is an integer index of dragged item
|
|
433
|
+
# drop_id:: is an integer index of drop location
|
|
434
|
+
# isshift:: boolean flag for if shift key held
|
|
435
|
+
# iscontrol:: boolean flag for if control key held
|
|
436
|
+
# callback should return Iup::CONTINUE for item to be moved/copied.
|
|
437
|
+
def dragdrop_cb callback
|
|
438
|
+
unless callback.arity == 4
|
|
439
|
+
raise ArgumentError, 'dragdrop_cb callback must take 4 arguments: (drag_id, drop_id, isshift, iscontrol)'
|
|
440
|
+
end
|
|
441
|
+
cb = Proc.new do |ih, drag_id, drop_id, isshift, iscontrol|
|
|
442
|
+
callback.call drag_id.to_i, drop_id.to_i, (isshift != 0), (iscontrol != 0)
|
|
443
|
+
end
|
|
444
|
+
define_callback cb, 'DRAGDROP_CB', :iiii_i
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
# Action generated when the mouse is moved.
|
|
448
|
+
# Callback takes 3 arguments: (x, y, state)
|
|
449
|
+
# x:: x position of mouse
|
|
450
|
+
# y:: y position of mouse
|
|
451
|
+
# state:: status of mouse buttons and certain keyboard keys at the moment the event was generated.
|
|
452
|
+
#--
|
|
453
|
+
# TODO: include functions, as in button_cb
|
|
454
|
+
#
|
|
455
|
+
def motion_cb callback
|
|
456
|
+
unless callback.arity == 3
|
|
457
|
+
raise ArgumentError, 'motion_cb callback must take 3 arguments: (x, y, state)'
|
|
458
|
+
end
|
|
459
|
+
cb = Proc.new do |ih, x, y, state|
|
|
460
|
+
callback.call x, y, state
|
|
461
|
+
end
|
|
462
|
+
define_callback cb, 'MOTION_CB', :iis_i
|
|
463
|
+
end
|
|
464
|
+
end
|
|
465
|
+
end
|
data/lib/wrapped/val.rb
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# Val is a control allowing the user to select a value within a limited range.
|
|
4
|
+
#
|
|
5
|
+
# == Attributes
|
|
6
|
+
#
|
|
7
|
+
# canfocus:: Enables the control to gain focus. Values 'yes' / 'no'.
|
|
8
|
+
# expand:: Allows button to fill available space in indicated direction.
|
|
9
|
+
# Values 'no' / 'horizontal' / 'vertical' / 'yes'.
|
|
10
|
+
# inverted:: If set, places maximum value on opposite side: values 'yes' / 'no'.
|
|
11
|
+
# max:: maximum value, defaults to 1.
|
|
12
|
+
# min:: minimum value, defaults to 0.
|
|
13
|
+
# orientation:: 'horizontal' / 'vertical'
|
|
14
|
+
# pagestep:: Proportion of increment for pageup / pagedown.
|
|
15
|
+
# Value between 0.0 and 1.0, default is 0.1.
|
|
16
|
+
# position:: <b>read-only</b> returns position in pixels within client window
|
|
17
|
+
# as "x,y".
|
|
18
|
+
# rastersize:: Size of the control, in pixels, value as "widthxheight".
|
|
19
|
+
# screenposition:: <b>read-only</b> returns position in pixels on screen
|
|
20
|
+
# as "x,y".
|
|
21
|
+
# step:: Proportion of increment for up / down.
|
|
22
|
+
# Value between 0.0 and 1.0, default is 0.01.
|
|
23
|
+
#
|
|
24
|
+
class Val < Widget
|
|
25
|
+
|
|
26
|
+
# Creates an instance of the control.
|
|
27
|
+
# orientation:: 'horizontal' / 'vertical'
|
|
28
|
+
# block:: optional block to set up control's attributes.
|
|
29
|
+
def initialize orientation=nil, &block
|
|
30
|
+
@handle = IupLib.IupVal orientation
|
|
31
|
+
|
|
32
|
+
# run any provided block on instance, to set up further attributes
|
|
33
|
+
self.instance_eval &block if block_given?
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# -- attributes
|
|
37
|
+
|
|
38
|
+
define_attribute :canfocus
|
|
39
|
+
define_attribute :expand
|
|
40
|
+
define_attribute :inverted
|
|
41
|
+
define_attribute :max
|
|
42
|
+
define_attribute :min
|
|
43
|
+
define_attribute :orientation
|
|
44
|
+
define_attribute :pagestep
|
|
45
|
+
define_readonly :position
|
|
46
|
+
define_attribute :rastersize
|
|
47
|
+
define_readonly :screenposition
|
|
48
|
+
define_attribute :step
|
|
49
|
+
define_attribute :value
|
|
50
|
+
|
|
51
|
+
# -- callbacks
|
|
52
|
+
|
|
53
|
+
# Calls callback when mouse button pressed to change the control value.
|
|
54
|
+
def button_press_cb callback
|
|
55
|
+
unless callback.arity.zero?
|
|
56
|
+
raise ArgumentError, 'button_press_cb callback must take 0 arguments'
|
|
57
|
+
end
|
|
58
|
+
cb = Proc.new do |ih|
|
|
59
|
+
callback.call
|
|
60
|
+
end
|
|
61
|
+
define_callback cb, 'BUTTON_PRESS_CB', :plain
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Calls callback when mouse button released.
|
|
65
|
+
def button_release_cb callback
|
|
66
|
+
unless callback.arity.zero?
|
|
67
|
+
raise ArgumentError, 'button_release_cb callback must take 0 arguments'
|
|
68
|
+
end
|
|
69
|
+
cb = Proc.new do |ih, a|
|
|
70
|
+
callback.call
|
|
71
|
+
end
|
|
72
|
+
define_callback cb, 'BUTTON_RELEASE_CB', :plain
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Calls callback when mouse is used to move control.
|
|
76
|
+
def mousemove_cb callback
|
|
77
|
+
unless callback.arity.zero?
|
|
78
|
+
raise ArgumentError, 'mousemove_cb callback must take 0 arguments'
|
|
79
|
+
end
|
|
80
|
+
cb = Proc.new do |ih, a|
|
|
81
|
+
callback.call
|
|
82
|
+
end
|
|
83
|
+
define_callback cb, 'MOUSEMOVE_CB', :plain
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Calls callback after the value was interactively changed by the user.
|
|
87
|
+
def valuechanged_cb callback
|
|
88
|
+
unless callback.arity.zero?
|
|
89
|
+
raise ArgumentError, 'valuechanged_cb callback must take 0 arguments'
|
|
90
|
+
end
|
|
91
|
+
cb = Proc.new do |ih|
|
|
92
|
+
callback.call
|
|
93
|
+
end
|
|
94
|
+
define_callback cb, 'VALUECHANGED_CB', :plain
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
data/lib/wrapped/vbox.rb
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# A container for one or more child widgets, arranged in a vertical column.
|
|
4
|
+
#
|
|
5
|
+
# == Attributes
|
|
6
|
+
#
|
|
7
|
+
# alignment:: horizontal alignment of children, 'atop' / 'acenter' / 'abottom'
|
|
8
|
+
# clientoffset:: read-only, returns current offset of box in its client
|
|
9
|
+
# as "widthxheight".
|
|
10
|
+
# clientsize:: read-only, returns current size of box as "widthxheight".
|
|
11
|
+
# expand:: Allows container to fill available space in indicated direction.
|
|
12
|
+
# Values 'no' / 'horizontal' / 'vertical' / 'yes'.
|
|
13
|
+
# expandchildren:: Set to allow children to expand fully, values as 'yes' / 'no'.
|
|
14
|
+
# gap:: Number of pixels between children, default value of 0.
|
|
15
|
+
# homogeneous:: Set to force all children to get equal size, values as 'yes' / 'no'.
|
|
16
|
+
# margin:: Margin in x and y directions, value as "mxn".
|
|
17
|
+
# normalsize:: Set to make natural size of children same, values as 'yes' / 'no'.
|
|
18
|
+
# position:: <b>read-only</b> returns position in pixels within client window
|
|
19
|
+
# as "x,y".
|
|
20
|
+
# rastersize:: Size of the container, in pixels, value as "widthxheight".
|
|
21
|
+
#
|
|
22
|
+
class VBox < Widget
|
|
23
|
+
include DynamicFillMethods
|
|
24
|
+
|
|
25
|
+
# Creates an instance of the vbox.
|
|
26
|
+
# *widgets:: one or more child widgets
|
|
27
|
+
# block:: optional block to set up the box's attributes.
|
|
28
|
+
def initialize *widgets, &block
|
|
29
|
+
@handle = IupLib.IupVbox *widget_list(widgets)
|
|
30
|
+
|
|
31
|
+
# run any provided block on instance, to set up further attributes
|
|
32
|
+
self.instance_eval &block if block_given?
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# -- attributes
|
|
36
|
+
|
|
37
|
+
define_attribute :alignment
|
|
38
|
+
define_readonly :clientoffset
|
|
39
|
+
define_readonly :clientsize
|
|
40
|
+
define_attribute :expand
|
|
41
|
+
define_attribute :expandchildren
|
|
42
|
+
define_attribute :gap
|
|
43
|
+
define_attribute :homogeneous
|
|
44
|
+
define_attribute :margin
|
|
45
|
+
define_attribute :normalizesize
|
|
46
|
+
define_readonly :position
|
|
47
|
+
define_attribute :rastersize
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
end
|