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/val.rb
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# An interactive control allowing the user to select a value within a limited
|
|
4
|
+
# range.
|
|
5
|
+
#
|
|
6
|
+
# === Example
|
|
7
|
+
#
|
|
8
|
+
# The following sets up a vertical control with a range from 0 to 10.
|
|
9
|
+
# As the slider is moved, a label's title is updated to the current value.
|
|
10
|
+
#
|
|
11
|
+
# Iup::Val.new('vertical') do |v|
|
|
12
|
+
# t.max = 10
|
|
13
|
+
# v.valuechanged_cb = ->{
|
|
14
|
+
# label.title = "VALUE=#{"%0.2f" % v.value}"
|
|
15
|
+
# Iup::DEFAULT
|
|
16
|
+
# }
|
|
17
|
+
# end
|
|
18
|
+
#
|
|
19
|
+
class Val < Iup::Widget
|
|
20
|
+
|
|
21
|
+
# Creates an instance of the control.
|
|
22
|
+
# If a block is given, the new instance is yielded to it.
|
|
23
|
+
# * +orientation+ - 'horizontal' / 'vertical'
|
|
24
|
+
def initialize(orientation='horizontal')
|
|
25
|
+
@handle = IupLib.IupVal(orientation)
|
|
26
|
+
|
|
27
|
+
# run any provided block on instance, to set up further attributes
|
|
28
|
+
yield self if block_given?
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# -- attributes
|
|
32
|
+
|
|
33
|
+
##
|
|
34
|
+
# :attr: canfocus
|
|
35
|
+
# Enables the control to gain focus. Values 'yes' / 'no'.
|
|
36
|
+
define_attribute :canfocus
|
|
37
|
+
|
|
38
|
+
##
|
|
39
|
+
# :attr: expand
|
|
40
|
+
# Allows button to fill available space in indicated direction.
|
|
41
|
+
# Values 'no' / 'horizontal' / 'vertical' / 'yes'.
|
|
42
|
+
define_attribute :expand
|
|
43
|
+
|
|
44
|
+
##
|
|
45
|
+
# :attr: inverted
|
|
46
|
+
# If set, places maximum value on opposite side: values 'yes' / 'no'.
|
|
47
|
+
define_attribute :inverted
|
|
48
|
+
|
|
49
|
+
##
|
|
50
|
+
# :attr: max
|
|
51
|
+
# Maximum value, defaults to 1.
|
|
52
|
+
define_attribute :max
|
|
53
|
+
|
|
54
|
+
##
|
|
55
|
+
# :attr: min
|
|
56
|
+
# Minimum value, defaults to 0.
|
|
57
|
+
define_attribute :min
|
|
58
|
+
|
|
59
|
+
##
|
|
60
|
+
# :attr: orientation
|
|
61
|
+
# Orientation of control: 'horizontal' / 'vertical'
|
|
62
|
+
define_attribute :orientation
|
|
63
|
+
|
|
64
|
+
##
|
|
65
|
+
# :attr: pagestep
|
|
66
|
+
# Proportion of increment for pageup / pagedown.
|
|
67
|
+
# Value between 0.0 and 1.0, default is 0.1.
|
|
68
|
+
define_attribute :pagestep
|
|
69
|
+
|
|
70
|
+
##
|
|
71
|
+
# :attr_reader: position
|
|
72
|
+
# Returns position in pixels within client window as "x,y".
|
|
73
|
+
define_reader :position
|
|
74
|
+
|
|
75
|
+
##
|
|
76
|
+
# :attr: rastersize
|
|
77
|
+
# Size of the control, in pixels, value as "widthxheight".
|
|
78
|
+
define_attribute :rastersize
|
|
79
|
+
|
|
80
|
+
##
|
|
81
|
+
# :attr_reader: screenposition
|
|
82
|
+
# Returns position in pixels on screen as "x,y".
|
|
83
|
+
define_reader :screenposition
|
|
84
|
+
|
|
85
|
+
##
|
|
86
|
+
# :attr: step
|
|
87
|
+
# Proportion of increment for up / down.
|
|
88
|
+
# Value between 0.0 and 1.0, default is 0.01.
|
|
89
|
+
define_attribute :step
|
|
90
|
+
|
|
91
|
+
##
|
|
92
|
+
# :attr: value
|
|
93
|
+
# Returns the current value of the control.
|
|
94
|
+
define_attribute :value
|
|
95
|
+
|
|
96
|
+
# :section: Callbacks
|
|
97
|
+
|
|
98
|
+
##
|
|
99
|
+
# :attr_writer: button_press_cb
|
|
100
|
+
# Calls callback when mouse button pressed to change the control value.
|
|
101
|
+
# Callback must respond to +call+ and take no arguments.
|
|
102
|
+
|
|
103
|
+
# --
|
|
104
|
+
def button_press_cb= callback
|
|
105
|
+
unless callback.arity.zero?
|
|
106
|
+
raise ArgumentError, 'button_press_cb callback must take 0 arguments'
|
|
107
|
+
end
|
|
108
|
+
cb = Proc.new do |ih|
|
|
109
|
+
callback.call
|
|
110
|
+
end
|
|
111
|
+
define_callback cb, 'BUTTON_PRESS_CB', :plain
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
##
|
|
115
|
+
# :attr_writer: button_release_cb
|
|
116
|
+
# Calls callback when mouse button released.
|
|
117
|
+
# Callback must respond to +call+ and take no arguments.
|
|
118
|
+
|
|
119
|
+
# --
|
|
120
|
+
def button_release_cb= callback
|
|
121
|
+
unless callback.arity.zero?
|
|
122
|
+
raise ArgumentError, 'button_release_cb callback must take 0 arguments'
|
|
123
|
+
end
|
|
124
|
+
cb = Proc.new do |ih, a|
|
|
125
|
+
callback.call
|
|
126
|
+
end
|
|
127
|
+
define_callback cb, 'BUTTON_RELEASE_CB', :plain
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
##
|
|
131
|
+
# :attr_writer: mousemove_cb
|
|
132
|
+
# Calls callback when mouse is used to move control.
|
|
133
|
+
# Callback must respond to +call+ and take no arguments.
|
|
134
|
+
|
|
135
|
+
# --
|
|
136
|
+
def mousemove_cb= callback
|
|
137
|
+
unless callback.arity.zero?
|
|
138
|
+
raise ArgumentError, 'mousemove_cb callback must take 0 arguments'
|
|
139
|
+
end
|
|
140
|
+
cb = Proc.new do |ih, a|
|
|
141
|
+
callback.call
|
|
142
|
+
end
|
|
143
|
+
define_callback cb, 'MOUSEMOVE_CB', :plain
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
##
|
|
147
|
+
# :attr_writer: valuechanged_cb
|
|
148
|
+
# Calls callback after the value was interactively changed by the user.
|
|
149
|
+
# Callback must respond to +call+ and take no arguments.
|
|
150
|
+
|
|
151
|
+
# --
|
|
152
|
+
def valuechanged_cb= callback
|
|
153
|
+
unless callback.arity.zero?
|
|
154
|
+
raise ArgumentError, 'valuechanged_cb callback must take 0 arguments'
|
|
155
|
+
end
|
|
156
|
+
cb = Proc.new do |ih|
|
|
157
|
+
callback.call
|
|
158
|
+
end
|
|
159
|
+
define_callback cb, 'VALUECHANGED_CB', :plain
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|
data/lib/wrapped/vbox.rb
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# A container for one or more child widgets, arranged in a vertical column.
|
|
4
|
+
#
|
|
5
|
+
# === Example
|
|
6
|
+
#
|
|
7
|
+
# This example arranges three buttons vertically with equal width, and some
|
|
8
|
+
# spacing:
|
|
9
|
+
#
|
|
10
|
+
# box = Iup::VBox.new(button1, button2, button3) do |b|
|
|
11
|
+
# b.gap = 10
|
|
12
|
+
# b.margin = '5x5'
|
|
13
|
+
# b.expandchildren = :yes
|
|
14
|
+
# end
|
|
15
|
+
#
|
|
16
|
+
# Also see: Fill, HBox
|
|
17
|
+
#
|
|
18
|
+
class VBox < Iup::Widget
|
|
19
|
+
include DynamicFillMethods
|
|
20
|
+
|
|
21
|
+
# Creates an instance of the vbox.
|
|
22
|
+
# If a block is given, the new instance is yielded to it.
|
|
23
|
+
#
|
|
24
|
+
# * +widgets+ - one or more child widgets
|
|
25
|
+
#
|
|
26
|
+
def initialize *widgets
|
|
27
|
+
@handle = IupLib.IupVbox(*widget_list(widgets))
|
|
28
|
+
|
|
29
|
+
# run any provided block on instance, to set up further attributes
|
|
30
|
+
yield self if block_given?
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# -- attributes
|
|
34
|
+
|
|
35
|
+
##
|
|
36
|
+
# :attr: alignment
|
|
37
|
+
# horizontal alignment of children, 'aleft' / 'acenter' / 'aright'
|
|
38
|
+
define_attribute :alignment
|
|
39
|
+
|
|
40
|
+
##
|
|
41
|
+
# :attr_reader: clientoffset
|
|
42
|
+
# returns current offset of box in its client as "widthxheight".
|
|
43
|
+
define_reader :clientoffset
|
|
44
|
+
|
|
45
|
+
##
|
|
46
|
+
# :attr_reader: clientsize
|
|
47
|
+
# returns current size of box as "widthxheight".
|
|
48
|
+
define_reader :clientsize
|
|
49
|
+
|
|
50
|
+
##
|
|
51
|
+
# :attr: expand
|
|
52
|
+
# Allows container to fill available space in indicated direction.
|
|
53
|
+
# Values 'no' / 'horizontal' / 'vertical' / 'yes'.
|
|
54
|
+
define_attribute :expand
|
|
55
|
+
|
|
56
|
+
##
|
|
57
|
+
# :attr: expandchildren
|
|
58
|
+
# Set to allow children to expand fully in horizontal direction, values as
|
|
59
|
+
# 'yes' / 'no'.
|
|
60
|
+
define_attribute :expandchildren
|
|
61
|
+
|
|
62
|
+
##
|
|
63
|
+
# :attr: gap
|
|
64
|
+
# Number of pixels between children, default value of 0.
|
|
65
|
+
define_attribute :gap
|
|
66
|
+
|
|
67
|
+
##
|
|
68
|
+
# :attr: homogeneous
|
|
69
|
+
# Set to force all children to get equal vertical size, values as 'yes' /
|
|
70
|
+
# 'no'.
|
|
71
|
+
define_attribute :homogeneous
|
|
72
|
+
|
|
73
|
+
##
|
|
74
|
+
# :attr: margin
|
|
75
|
+
# Margin in x and y directions, value as "mxn".
|
|
76
|
+
define_attribute :margin
|
|
77
|
+
|
|
78
|
+
##
|
|
79
|
+
# :attr: normalsize
|
|
80
|
+
# Set to make natural size of children same, values as 'yes' / 'no'.
|
|
81
|
+
define_attribute :normalizesize
|
|
82
|
+
|
|
83
|
+
##
|
|
84
|
+
# :attr_reader: position
|
|
85
|
+
# returns position in pixels within client window as "x,y".
|
|
86
|
+
define_reader :position
|
|
87
|
+
|
|
88
|
+
##
|
|
89
|
+
# :attr: rastersize
|
|
90
|
+
# Size of the container, in pixels, value as "widthxheight".
|
|
91
|
+
define_attribute :rastersize
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# This class provides shared functionality across all widgets in the
|
|
4
|
+
# IUP library.
|
|
5
|
+
#
|
|
6
|
+
# Every widget has a +handle+, which is often a C pointer:
|
|
7
|
+
#
|
|
8
|
+
# p Iup::Button.new.handle
|
|
9
|
+
# # => #<FFI::Pointer address=0x0000647e530e6a80>
|
|
10
|
+
#
|
|
11
|
+
# The Widget class provides attributes supporting appearance,
|
|
12
|
+
# including whether the widget is active, its size, font and color, and its
|
|
13
|
+
# position in the z-order list (where widgets are overlapping, and the top
|
|
14
|
+
# one is visible).
|
|
15
|
+
#
|
|
16
|
+
# Some common callbacks are also found in this class, responding to:
|
|
17
|
+
# * map/unmap, where the native interface elements are created. Some child
|
|
18
|
+
# widgets require their parent to be mapped first.
|
|
19
|
+
# * focus events.
|
|
20
|
+
# * keyboard/mouse events.
|
|
21
|
+
#
|
|
22
|
+
# === Example
|
|
23
|
+
#
|
|
24
|
+
# The following code creates a button with large red text,
|
|
25
|
+
# which reports when the mouse moves over the button and any key is pressed:
|
|
26
|
+
#
|
|
27
|
+
# Iup::mainloop do
|
|
28
|
+
# btn = Iup::Button.new("hello") do
|
|
29
|
+
# it.fgcolor = "255 0 0"
|
|
30
|
+
# it.font = "Times, Bold 18"
|
|
31
|
+
# it.enterwindow_cb = ->{ puts "on button" }
|
|
32
|
+
# it.leavewindow_cb = ->{ puts "off button" }
|
|
33
|
+
# it.k_any = ->(k){ puts "Key #{k.chr}" }
|
|
34
|
+
# end
|
|
35
|
+
#
|
|
36
|
+
# Iup::Dialog.new(btn).show
|
|
37
|
+
# end
|
|
38
|
+
#
|
|
39
|
+
class Widget
|
|
40
|
+
extend AttributeBuilders
|
|
41
|
+
include CallbackSetter
|
|
42
|
+
|
|
43
|
+
# Unique reference to widget.
|
|
44
|
+
attr_accessor :handle
|
|
45
|
+
|
|
46
|
+
# Sets the internal handle name for this widget.
|
|
47
|
+
def assign_handle name
|
|
48
|
+
IupLib.IupSetHandle(name, @handle)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
@@controlslib = false
|
|
52
|
+
|
|
53
|
+
# Ensure the controls library is opened
|
|
54
|
+
def open_controls
|
|
55
|
+
unless @@controlslib
|
|
56
|
+
ControlsLib.IupControlsOpen
|
|
57
|
+
@@controlslib = true
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
## -- common attributes
|
|
62
|
+
|
|
63
|
+
##
|
|
64
|
+
# :attr: active
|
|
65
|
+
# Enables or prevents user interaction.
|
|
66
|
+
# Typically, a widget will appear greyed-out when inactive.
|
|
67
|
+
# Values 'yes' / 'no'.
|
|
68
|
+
define_attribute :active
|
|
69
|
+
|
|
70
|
+
##
|
|
71
|
+
# :attr: bgcolor
|
|
72
|
+
# Specify RGB values for background color, as "r g b".
|
|
73
|
+
define_attribute :bgcolor
|
|
74
|
+
|
|
75
|
+
##
|
|
76
|
+
# :attr: fgcolor
|
|
77
|
+
# Specify RGB values for foreground color, as "r g b".
|
|
78
|
+
define_attribute :fgcolor
|
|
79
|
+
|
|
80
|
+
##
|
|
81
|
+
# :attr: font
|
|
82
|
+
# Sets the widget's font, using a font description as "<font face>, <font
|
|
83
|
+
# styles> <font size>", e.g. "Times, Bold 14".
|
|
84
|
+
# For portability, the fonts Courier, Helvetica and Times are always mapped
|
|
85
|
+
# to appropriate native system fonts.
|
|
86
|
+
define_attribute :font
|
|
87
|
+
|
|
88
|
+
##
|
|
89
|
+
# :attr: visible
|
|
90
|
+
# Shows or hides the widget. Values 'yes' / 'no'.
|
|
91
|
+
define_attribute :visible
|
|
92
|
+
|
|
93
|
+
##
|
|
94
|
+
# :attr: maxsize
|
|
95
|
+
# Maximum size of widget, value as "widthxheight".
|
|
96
|
+
define_attribute :maxsize
|
|
97
|
+
|
|
98
|
+
##
|
|
99
|
+
# :attr: minsize
|
|
100
|
+
# Minimum size of widget, value as "widthxheight".
|
|
101
|
+
define_attribute :minsize
|
|
102
|
+
|
|
103
|
+
##
|
|
104
|
+
# :attr: size
|
|
105
|
+
# Size of the widget, in character units, value as "widthxheight".
|
|
106
|
+
define_attribute :size
|
|
107
|
+
|
|
108
|
+
##
|
|
109
|
+
# :attr_reader: wid
|
|
110
|
+
# Native widget identifier.
|
|
111
|
+
define_reader :wid
|
|
112
|
+
|
|
113
|
+
##
|
|
114
|
+
# :attr_writer: zorder
|
|
115
|
+
# Alters z-order, values as 'top' / 'bottom'.
|
|
116
|
+
define_writer :zorder
|
|
117
|
+
|
|
118
|
+
# When no longer required, call +destroy+ to have the C backend
|
|
119
|
+
# reclaim the widget.
|
|
120
|
+
def destroy
|
|
121
|
+
IupLib.IupDestroy @handle
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# :section: Callbacks
|
|
125
|
+
|
|
126
|
+
##
|
|
127
|
+
# :attr_writer: map_cb
|
|
128
|
+
#
|
|
129
|
+
# Called right after a widget is mapped and its layout updated.
|
|
130
|
+
# Callback must respond to +call+ and take no arguments.
|
|
131
|
+
|
|
132
|
+
# --
|
|
133
|
+
def map_cb= callback
|
|
134
|
+
unless callback.arity.zero?
|
|
135
|
+
raise ArgumentError, 'map_cb callback must take 0 arguments'
|
|
136
|
+
end
|
|
137
|
+
cb = Proc.new do |ih|
|
|
138
|
+
callback.call
|
|
139
|
+
end
|
|
140
|
+
define_callback cb, 'MAP_CB', :plain
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
##
|
|
144
|
+
# :attr_writer: unmap_cb
|
|
145
|
+
#
|
|
146
|
+
# Called right before a widget is unmapped.
|
|
147
|
+
# Callback must respond to +call+ and take no arguments.
|
|
148
|
+
|
|
149
|
+
# --
|
|
150
|
+
def unmap_cb= callback
|
|
151
|
+
unless callback.arity.zero?
|
|
152
|
+
raise ArgumentError, 'unmap_cb callback must take 0 arguments'
|
|
153
|
+
end
|
|
154
|
+
cb = Proc.new do |ih|
|
|
155
|
+
callback.call
|
|
156
|
+
end
|
|
157
|
+
define_callback cb, 'UNMAP_CB', :plain
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
##
|
|
161
|
+
# :attr_writer: getfocus_cb
|
|
162
|
+
#
|
|
163
|
+
# Action generated when a widget is given keyboard focus.
|
|
164
|
+
# Callback must respond to +call+ and take no arguments.
|
|
165
|
+
|
|
166
|
+
# --
|
|
167
|
+
def getfocus_cb= callback
|
|
168
|
+
unless callback.arity.zero?
|
|
169
|
+
raise ArgumentError, 'getfocus_cb callback must take 0 arguments'
|
|
170
|
+
end
|
|
171
|
+
cb = Proc.new do |ih|
|
|
172
|
+
callback.call
|
|
173
|
+
end
|
|
174
|
+
define_callback cb, 'GETFOCUS_CB', :plain
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
##
|
|
178
|
+
# :attr_writer: killfocus_cb
|
|
179
|
+
#
|
|
180
|
+
# Action generated when a widget loses keyboard focus.
|
|
181
|
+
# Callback must respond to +call+ and take no arguments.
|
|
182
|
+
|
|
183
|
+
# --
|
|
184
|
+
def killfocus_cb= callback
|
|
185
|
+
unless callback.arity.zero?
|
|
186
|
+
raise ArgumentError, 'killfocus_cb callback must take 0 arguments'
|
|
187
|
+
end
|
|
188
|
+
cb = Proc.new do |ih|
|
|
189
|
+
callback.call
|
|
190
|
+
end
|
|
191
|
+
define_callback cb, 'KILLFOCUS_CB', :plain
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
##
|
|
195
|
+
# :attr_writer: enterwindow_cb
|
|
196
|
+
#
|
|
197
|
+
# Action generated when the mouse enters the widget.
|
|
198
|
+
# Callback must respond to +call+ and take no arguments.
|
|
199
|
+
|
|
200
|
+
# --
|
|
201
|
+
def enterwindow_cb= callback
|
|
202
|
+
unless callback.arity.zero?
|
|
203
|
+
raise ArgumentError, 'enterwindow_cb callback must take 0 arguments'
|
|
204
|
+
end
|
|
205
|
+
cb = Proc.new do |ih|
|
|
206
|
+
callback.call
|
|
207
|
+
end
|
|
208
|
+
define_callback cb, 'ENTERWINDOW_CB', :plain
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
##
|
|
212
|
+
# :attr_writer: leavewindow_cb
|
|
213
|
+
#
|
|
214
|
+
# Action generated when the mouse leaves the widget.
|
|
215
|
+
# Callback must respond to +call+ and take no arguments.
|
|
216
|
+
|
|
217
|
+
# --
|
|
218
|
+
def leavewindow_cb= callback
|
|
219
|
+
unless callback.arity.zero?
|
|
220
|
+
raise ArgumentError, 'leavewindow_cb callback must take 0 arguments'
|
|
221
|
+
end
|
|
222
|
+
cb = Proc.new do |ih|
|
|
223
|
+
callback.call
|
|
224
|
+
end
|
|
225
|
+
define_callback cb, 'LEAVEWINDOW_CB', :plain
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
##
|
|
229
|
+
# :attr_writer: k_any
|
|
230
|
+
#
|
|
231
|
+
# Action generated when a keyboard event occurs.
|
|
232
|
+
# Callback must respond to +call+ and takes 1-argument: (key)
|
|
233
|
+
# * +key+ - the character that is pressed, see {Key definitions}[../Iup.html#Key+definitions].
|
|
234
|
+
|
|
235
|
+
# --
|
|
236
|
+
def k_any= callback
|
|
237
|
+
unless callback.arity == 1
|
|
238
|
+
raise ArgumentError, 'k_any callback must take 1 argument, a character'
|
|
239
|
+
end
|
|
240
|
+
cb = Proc.new do |ih, c|
|
|
241
|
+
callback.call c
|
|
242
|
+
end
|
|
243
|
+
define_callback cb, 'K_ANY', :i_i
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
##
|
|
247
|
+
# :attr_writer: help_cb
|
|
248
|
+
#
|
|
249
|
+
# Action generated when the user presses F1 at a control.
|
|
250
|
+
# Callback must respond to +call+ and take no arguments.
|
|
251
|
+
|
|
252
|
+
# --
|
|
253
|
+
def help_cb= callback
|
|
254
|
+
unless callback.arity.zero?
|
|
255
|
+
raise ArgumentError, 'help_cb callback must take 0 arguments'
|
|
256
|
+
end
|
|
257
|
+
cb = Proc.new do |ih|
|
|
258
|
+
callback.call
|
|
259
|
+
end
|
|
260
|
+
define_callback cb, 'HELP_CB', :plain_v
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
# :section:
|
|
264
|
+
|
|
265
|
+
private
|
|
266
|
+
|
|
267
|
+
# given an array of widgets,
|
|
268
|
+
# convert into format widget1, :pointer, widget2, ... , :pointer, nil
|
|
269
|
+
def widget_list widgets
|
|
270
|
+
result = []
|
|
271
|
+
|
|
272
|
+
widgets.each do |widget|
|
|
273
|
+
result << widget.handle
|
|
274
|
+
result << :pointer
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
result << nil
|
|
278
|
+
|
|
279
|
+
return result
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
end
|
data/lib/wrapped/zbox.rb
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# A container of a list of widgets, but only displays one of them.
|
|
4
|
+
#
|
|
5
|
+
# === Example
|
|
6
|
+
#
|
|
7
|
+
# The following example stores four widgets and displays the +label+:
|
|
8
|
+
#
|
|
9
|
+
# zbox = Iup::ZBox.new(frame, text, label, button) do |b|
|
|
10
|
+
# b.alignment = 'acenter'
|
|
11
|
+
# b.expand = 'yes'
|
|
12
|
+
# b.valuepos = 2
|
|
13
|
+
# end
|
|
14
|
+
#
|
|
15
|
+
# Also see: HBox, Tabs, VBox
|
|
16
|
+
#
|
|
17
|
+
class ZBox < Iup::Widget
|
|
18
|
+
include DynamicFillMethods
|
|
19
|
+
|
|
20
|
+
# Creates a new instance.
|
|
21
|
+
# If a block is given, the new instance is yielded to it.
|
|
22
|
+
#
|
|
23
|
+
# * +widgets+ - one or more child widgets
|
|
24
|
+
#
|
|
25
|
+
def initialize *widgets
|
|
26
|
+
@handle = IupLib.IupZbox(*widget_list(widgets))
|
|
27
|
+
|
|
28
|
+
# run any provided block on instance, to set up further attributes
|
|
29
|
+
yield self if block_given?
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# -- attributes
|
|
33
|
+
|
|
34
|
+
##
|
|
35
|
+
# :attr: valuepos
|
|
36
|
+
# The visible child, accessed by its index position, 0-indexed.
|
|
37
|
+
|
|
38
|
+
# --
|
|
39
|
+
def valuepos
|
|
40
|
+
IupLib.IupGetAttribute(@handle, 'VALUEPOS').first.to_i
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def valuepos= val # :nodoc:
|
|
44
|
+
IupLib.IupSetAttribute(@handle, 'VALUEPOS', val.to_s)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
##
|
|
48
|
+
# :attr: alignment
|
|
49
|
+
# alignment of visible child.
|
|
50
|
+
# Values: 'north' / 'south' / 'east' / 'west'/ 'ne' / 'nw' / 'se' / 'sw' / 'acenter'
|
|
51
|
+
define_attribute :alignment
|
|
52
|
+
|
|
53
|
+
##
|
|
54
|
+
# :attr_reader: clientoffset
|
|
55
|
+
# returns current offset of box in its client as "widthxheight".
|
|
56
|
+
define_reader :clientoffset
|
|
57
|
+
|
|
58
|
+
##
|
|
59
|
+
# :attr_reader: clientsize
|
|
60
|
+
# returns current size of box as "widthxheight".
|
|
61
|
+
define_reader :clientsize
|
|
62
|
+
|
|
63
|
+
##
|
|
64
|
+
# :attr: expand
|
|
65
|
+
# Allows container to fill available space in indicated direction.
|
|
66
|
+
# Values 'no' / 'horizontal' / 'vertical' / 'yes'.
|
|
67
|
+
define_attribute :expand
|
|
68
|
+
|
|
69
|
+
##
|
|
70
|
+
# :attr: rastersize
|
|
71
|
+
# Size of the container, in pixels, value as "widthxheight".
|
|
72
|
+
define_attribute :rastersize
|
|
73
|
+
|
|
74
|
+
##
|
|
75
|
+
# :attr: size
|
|
76
|
+
# Size of the container, in character units, value as "widthxheight".
|
|
77
|
+
define_attribute :size
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|