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/text.rb
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# A Text control is one of the more complex controls, because it can be
|
|
4
|
+
# displayed in a variety of ways:
|
|
5
|
+
#
|
|
6
|
+
# (1) a single line, for inputting a single line of text.
|
|
7
|
+
#
|
|
8
|
+
# Text.new do
|
|
9
|
+
# expand 'horizontal'
|
|
10
|
+
# nc 5
|
|
11
|
+
# end
|
|
12
|
+
#
|
|
13
|
+
# (2) a multi-line control, to act more like an editor.
|
|
14
|
+
#
|
|
15
|
+
# Text.new do
|
|
16
|
+
# multiline 'yes'
|
|
17
|
+
# expand 'yes'
|
|
18
|
+
# size '200x100'
|
|
19
|
+
# end
|
|
20
|
+
#
|
|
21
|
+
# (3) a spin box, for selecting one of several values.
|
|
22
|
+
#
|
|
23
|
+
# Text.new do
|
|
24
|
+
# spin 'yes'
|
|
25
|
+
# spinmax 20
|
|
26
|
+
# spinmin 10
|
|
27
|
+
# expand 'horizontal'
|
|
28
|
+
# spin_cb ->(v){
|
|
29
|
+
# puts "spin control is now #{v}"
|
|
30
|
+
# DEFAULT
|
|
31
|
+
# }
|
|
32
|
+
# end
|
|
33
|
+
#
|
|
34
|
+
# == Attributes
|
|
35
|
+
#
|
|
36
|
+
# alignment:: Sets the alignment of text within control,
|
|
37
|
+
# options ALEFT, ACENTER, ARIGHT or none.
|
|
38
|
+
# append:: <b>write-only</b> appends given string to end of text.
|
|
39
|
+
# autohide:: If set, scrollbars are only shown if necessary, values 'yes' / 'no'.
|
|
40
|
+
# border:: Sets border around text, values 'yes' / 'no'.
|
|
41
|
+
# canfocus:: If set, the control can gain focus, values 'yes' / 'no'.
|
|
42
|
+
# caret:: 'col' in single-line mode, sets column number of caret;
|
|
43
|
+
# 'lin,col' in multi-line mode, sets line and column number of caret.
|
|
44
|
+
# caretpos:: Index of character of the insertion point.
|
|
45
|
+
# clipboard:: 'clear' / 'copy' / 'cut' / 'paste', <b>write-only</b> access the
|
|
46
|
+
# clipboard with the current selection.
|
|
47
|
+
# count:: <b>read-only</b> number of characters in text.
|
|
48
|
+
# expand:: Allows control to fill available space in indicated direction.
|
|
49
|
+
# Values 'no' / 'horizontal' / 'vertical' / 'yes'.
|
|
50
|
+
# formatting:: Set to 'yes' in multi-line mode, to allow control to use
|
|
51
|
+
# formatting of text.
|
|
52
|
+
# insert:: <b>write-only</b> Places a given string at current caret position,
|
|
53
|
+
# overwriting any current selection.
|
|
54
|
+
# linecount:: <b>read-only</b> returns number of lines of text.
|
|
55
|
+
# linevalue:: <b>read-only</b> returns line of text where the caret is.
|
|
56
|
+
# mask:: Defines a mask to filter text input.
|
|
57
|
+
# multiline:: 'no' / 'yes'
|
|
58
|
+
# nc:: Maximum number of characters allowed for keyboard input (0 allows an indefinite number).
|
|
59
|
+
# overwrite:: 'off' / 'on', used when formatting=yes.
|
|
60
|
+
# padding:: Margin in x and y directions, value as "mxn".
|
|
61
|
+
# password:: 'yes' / 'no', if set, masks the input text as "*".
|
|
62
|
+
# position:: <b>read-only</b> returns position in pixels within client window
|
|
63
|
+
# as "x,y".
|
|
64
|
+
# rastersize:: Size of the list, in pixels, value as "widthxheight".
|
|
65
|
+
# readonly:: 'yes' / 'no'.
|
|
66
|
+
# screenposition:: <b>read-only</b> returns position in pixels on screen
|
|
67
|
+
# as "x,y".
|
|
68
|
+
# scrollbar:: In multi-line mode, selects 'no' / 'horizontal' / 'vertical' / 'yes' (for both) scrollbars.
|
|
69
|
+
# scrollto:: <b>write-only</b>
|
|
70
|
+
# 'col' Scrolls to make given column number visible,
|
|
71
|
+
# in single-line mode.
|
|
72
|
+
# 'lin/col' Scrolls to make line and column number visible,
|
|
73
|
+
# in multi-line mode.
|
|
74
|
+
# scrolltopos:: <b>write-only</b> Scrolls to make character 'number' visible.
|
|
75
|
+
# selectedtext:: Reads or overwrites the current selection.
|
|
76
|
+
# Does nothing if no text is selected.
|
|
77
|
+
# selection:: Selects text as 'col1:col2' (single-line) / 'lin1,col1:lin2,col2' (multi-line) / 'all' / 'none'.
|
|
78
|
+
# selectionpos:: Selects text between character positions: 'pos1:pos2' / 'all' / 'none'.
|
|
79
|
+
# spin:: 'no' / 'yes', attaches a spin control to the text box.
|
|
80
|
+
# spinalign:: 'right' / 'left', with respect to the text (GTK always 'right').
|
|
81
|
+
# spinauto:: 'yes' / 'no', updates value of control when spin buttons used.
|
|
82
|
+
# When 'no', "spin_cb" must adjust the value.
|
|
83
|
+
# spininc:: Increment value, defaults to 1.
|
|
84
|
+
# spinmax:: Maximum spin value, defaults to 100.
|
|
85
|
+
# spinmin:: Minimum spin value, defaults to 1.
|
|
86
|
+
# spinvalue:: Current value of spin, defaults to 1.
|
|
87
|
+
# spinwrap:: 'no' / 'yes', automatically wraps spin at ends of range, when set.
|
|
88
|
+
# tabsize:: In multi-line mode, controls number of spaces used for a tab, defaults to 8.
|
|
89
|
+
# tip:: Tooltip string.
|
|
90
|
+
# value:: Retrieves or sets the text.
|
|
91
|
+
# valuemasked:: Retrieves or sets the text, applying +MASK+ when setting.
|
|
92
|
+
# visiblecolumns:: The minimum number of visible columns, defaults to 5.
|
|
93
|
+
# visiblelines:: The minimum number of visible lines, when dropdown=no.
|
|
94
|
+
# wordwrap:: 'no' / 'yes', when multiline=yes.
|
|
95
|
+
#
|
|
96
|
+
#--
|
|
97
|
+
# TODO Formatting
|
|
98
|
+
#
|
|
99
|
+
class Text < Widget
|
|
100
|
+
include DragDropAttributes
|
|
101
|
+
|
|
102
|
+
def initialize &block
|
|
103
|
+
@handle = IupLib.IupText nil
|
|
104
|
+
|
|
105
|
+
# run any provided block on instance, to set up further attributes
|
|
106
|
+
self.instance_eval &block if block_given?
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# -- attributes
|
|
110
|
+
|
|
111
|
+
define_attribute :alignment
|
|
112
|
+
define_writeonly :append
|
|
113
|
+
define_attribute :autohide
|
|
114
|
+
define_attribute :border
|
|
115
|
+
define_attribute :canfocus
|
|
116
|
+
define_attribute :caret
|
|
117
|
+
define_attribute :caretpos
|
|
118
|
+
define_attribute :clipboard
|
|
119
|
+
define_readonly :count
|
|
120
|
+
define_attribute :expand
|
|
121
|
+
define_attribute :formatting
|
|
122
|
+
define_writeonly :insert
|
|
123
|
+
define_readonly :linecount
|
|
124
|
+
define_readonly :linevalue
|
|
125
|
+
define_attribute :mask
|
|
126
|
+
define_attribute :multiline
|
|
127
|
+
define_attribute :nc
|
|
128
|
+
define_attribute :overwrite
|
|
129
|
+
define_attribute :padding
|
|
130
|
+
define_attribute :password
|
|
131
|
+
define_attribute :position
|
|
132
|
+
define_attribute :rastersize
|
|
133
|
+
define_attribute :readonly
|
|
134
|
+
define_readonly :scrollbar
|
|
135
|
+
define_attribute :scrollto
|
|
136
|
+
define_attribute :scrolltopos
|
|
137
|
+
define_attribute :selectedtext
|
|
138
|
+
define_attribute :selection
|
|
139
|
+
define_attribute :selectionpos
|
|
140
|
+
define_attribute :spin
|
|
141
|
+
define_attribute :spinalign
|
|
142
|
+
define_attribute :spinauto
|
|
143
|
+
define_attribute :spininc
|
|
144
|
+
define_attribute :spinmax
|
|
145
|
+
define_attribute :spinmin
|
|
146
|
+
define_attribute :spinvalue
|
|
147
|
+
define_attribute :spinwrap
|
|
148
|
+
define_attribute :tabsize
|
|
149
|
+
define_attribute :tip
|
|
150
|
+
define_attribute :value
|
|
151
|
+
define_attribute :valuemasked
|
|
152
|
+
define_attribute :visiblecolumns
|
|
153
|
+
define_attribute :visiblelines
|
|
154
|
+
define_attribute :wordwrap
|
|
155
|
+
|
|
156
|
+
# -- callbacks
|
|
157
|
+
|
|
158
|
+
# Action generated when the text is edited, but before its value is actually changed.
|
|
159
|
+
# action takes a 2-argument callback, the character typed and the new value.
|
|
160
|
+
def action callback
|
|
161
|
+
unless callback.arity == 2
|
|
162
|
+
raise ArgumentError, 'action callback must take 2 argument: (character, new-text)'
|
|
163
|
+
end
|
|
164
|
+
cb = Proc.new do |ih, c, text|
|
|
165
|
+
callback.call c, text
|
|
166
|
+
end
|
|
167
|
+
define_callback cb, 'ACTION', :is_i
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
include ButtonCallback
|
|
171
|
+
|
|
172
|
+
# Action generated when the caret/cursor position is changed.
|
|
173
|
+
# caret_cb takes a callback which accepts 3 arguments (line, column, position) of caret
|
|
174
|
+
def caret_cb callback
|
|
175
|
+
unless callback.arity == 3
|
|
176
|
+
raise ArgumentError, 'caret_cb callback must take 3 arguments: (line, column, position)'
|
|
177
|
+
end
|
|
178
|
+
cb = Proc.new do |ih, lin, col, pos|
|
|
179
|
+
callback.call lin, col, pos
|
|
180
|
+
end
|
|
181
|
+
define_callback cb, 'CARET_CB', :iii_i
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# Action generated when the mouse is moved.
|
|
185
|
+
# Callback takes 3 arguments: (x, y, state)
|
|
186
|
+
# x:: x position of mouse
|
|
187
|
+
# y:: y position of mouse
|
|
188
|
+
# state:: status of mouse buttons and certain keyboard keys at the moment the event was generated.
|
|
189
|
+
#--
|
|
190
|
+
# TODO: include functions, as in button_cb
|
|
191
|
+
#
|
|
192
|
+
def motion_cb callback
|
|
193
|
+
unless callback.arity == 3
|
|
194
|
+
raise ArgumentError, 'motion_cb callback must take 3 arguments: (x, y, state)'
|
|
195
|
+
end
|
|
196
|
+
cb = Proc.new do |ih, x, y, state|
|
|
197
|
+
callback.call x, y, state
|
|
198
|
+
end
|
|
199
|
+
define_callback cb, 'MOTION_CB', :iis_i
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
# Action generated when a spin button is pressed. Valid only when SPIN=YES.
|
|
203
|
+
# spin takes a 1-argument callback, the value of spin.
|
|
204
|
+
def spin_cb callback
|
|
205
|
+
unless callback.arity == 1
|
|
206
|
+
raise ArgumentError, 'spin_cb callback must take 1 argument, the value'
|
|
207
|
+
end
|
|
208
|
+
cb = Proc.new do |ih, val|
|
|
209
|
+
callback.call val
|
|
210
|
+
end
|
|
211
|
+
define_callback cb, 'SPIN_CB', :i_i
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# Called after the value was interactively changed by the user.
|
|
215
|
+
def valuechanged_cb callback
|
|
216
|
+
unless callback.arity.zero?
|
|
217
|
+
raise ArgumentError, 'valuechanged_cb callback must take 0 arguments'
|
|
218
|
+
end
|
|
219
|
+
cb = Proc.new do |ih|
|
|
220
|
+
callback.call
|
|
221
|
+
end
|
|
222
|
+
define_callback cb, 'VALUECHANGED_CB', :plain
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
class Timer
|
|
4
|
+
extend AttributeBuilders
|
|
5
|
+
include CallbackSetter
|
|
6
|
+
|
|
7
|
+
attr_reader :handle
|
|
8
|
+
|
|
9
|
+
def initialize &block
|
|
10
|
+
@handle = IupLib.IupTimer
|
|
11
|
+
|
|
12
|
+
# run any provided block on instance, to set up further attributes
|
|
13
|
+
self.instance_eval &block if block_given?
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# must be called when Timer is finished with
|
|
17
|
+
def destroy
|
|
18
|
+
IupLib.IupDestroy @handle
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# -- attributes
|
|
22
|
+
|
|
23
|
+
define_attribute :time
|
|
24
|
+
define_attribute :run
|
|
25
|
+
define_readonly :wid
|
|
26
|
+
|
|
27
|
+
# -- callbacks
|
|
28
|
+
|
|
29
|
+
# Called when the time is up.
|
|
30
|
+
# Return CLOSE to end application.
|
|
31
|
+
def action_cb callback
|
|
32
|
+
unless callback.arity.zero?
|
|
33
|
+
raise ArgumentError, 'action_cb must take 0 arguments'
|
|
34
|
+
end
|
|
35
|
+
cb = Proc.new do |ih|
|
|
36
|
+
callback.call
|
|
37
|
+
end
|
|
38
|
+
define_callback cb, 'ACTION_CB', :plain
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# A Toggle control is a control that can have two or three states.
|
|
4
|
+
# The toggle control will display some text or an image.
|
|
5
|
+
#
|
|
6
|
+
# == Attributes
|
|
7
|
+
#
|
|
8
|
+
# alignment:: Sets the horizontal and vertical alignment.
|
|
9
|
+
# The value is a string "horizontal:vertical", with
|
|
10
|
+
# options ALEFT, ACENTER, ARIGHT or none.
|
|
11
|
+
# canfocus:: Enables the control to gain focus. Values 'yes' / 'no'.
|
|
12
|
+
# expand:: Allows control to fill available space in indicated direction.
|
|
13
|
+
# Values 'no' / 'horizontal' / 'vertical' / 'yes'.
|
|
14
|
+
# flat:: If set, hides the control's border until mouse enters the button area.
|
|
15
|
+
# Values 'yes' / 'no'.
|
|
16
|
+
# image:: Sets the image to display.
|
|
17
|
+
# This can be an actual image object, or the name of an image.
|
|
18
|
+
# iminactive:: Sets the image to display when inactive.
|
|
19
|
+
# impress:: Sets the image to display when pressed.
|
|
20
|
+
# padding:: Margin in x and y directions, value as "mxn".
|
|
21
|
+
# position:: <b>read-only</b> returns position in pixels within client window
|
|
22
|
+
# as "x,y".
|
|
23
|
+
# radio:: <b>read-only</b> Returns 'yes' / 'no' if toggle within a radio control.
|
|
24
|
+
# rastersize:: Size of the control, in pixels, value as "widthxheight".
|
|
25
|
+
# screenposition:: <b>read-only</b> returns position in pixels on screen
|
|
26
|
+
# as "x,y".
|
|
27
|
+
# three_state:: 'no' / 'yes', 3-state only for text labels
|
|
28
|
+
# tip:: Tooltip string.
|
|
29
|
+
# title:: text to display.
|
|
30
|
+
# value:: 'on' / 'off' / 'toggle' / 'notdef' (for 3-state toggles).
|
|
31
|
+
#
|
|
32
|
+
class Toggle < Widget
|
|
33
|
+
include ImageAttributes
|
|
34
|
+
|
|
35
|
+
# Creates an instance of a Toggle control.
|
|
36
|
+
# title:: optional text to display
|
|
37
|
+
# arg:: optional name of action to perform when state changed
|
|
38
|
+
# block:: optional block to set up attributes.
|
|
39
|
+
def initialize title=nil, arg='', &block
|
|
40
|
+
@handle = IupLib.IupToggle title, arg
|
|
41
|
+
|
|
42
|
+
# run any provided block on instance, to set up further attributes
|
|
43
|
+
self.instance_eval &block if block_given?
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# -- attributes
|
|
47
|
+
|
|
48
|
+
define_attribute :alignment
|
|
49
|
+
define_attribute :canfocus
|
|
50
|
+
define_attribute :expand
|
|
51
|
+
define_attribute :flat
|
|
52
|
+
define_attribute :padding
|
|
53
|
+
define_readonly :position
|
|
54
|
+
define_attribute :radio
|
|
55
|
+
define_attribute :rastersize
|
|
56
|
+
define_readonly :screenposition
|
|
57
|
+
define_attribute :tip
|
|
58
|
+
define_attribute :title
|
|
59
|
+
define_attribute :value
|
|
60
|
+
|
|
61
|
+
def three_state val=nil # :nodoc:
|
|
62
|
+
if val.nil?
|
|
63
|
+
IupLib.IupGetAttribute(@handle, '3STATE').first
|
|
64
|
+
else
|
|
65
|
+
IupLib.IupGetAttribute(@handle, '3STATE', val).first
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# -- callbacks
|
|
70
|
+
|
|
71
|
+
# Action generated when the toggle's state (on/off) was changed.
|
|
72
|
+
# action takes a 1-argument callback, the argument
|
|
73
|
+
# indicating the state change.
|
|
74
|
+
# state_change == 1 if state changed to "on"
|
|
75
|
+
# state_change == 0 if state changed to "off"
|
|
76
|
+
def action callback
|
|
77
|
+
unless callback.arity == 1
|
|
78
|
+
raise ArgumentError, 'action callback must take 1 argument, the state_change'
|
|
79
|
+
end
|
|
80
|
+
cb = Proc.new do |ih, state_change|
|
|
81
|
+
callback.call state_change.to_i
|
|
82
|
+
end
|
|
83
|
+
define_callback cb, 'ACTION', :i_i
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Called 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
|
|
98
|
+
|