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
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# Displays a palette of colors from which the user can select a primary and
|
|
4
|
+
# secondary color.
|
|
5
|
+
#
|
|
6
|
+
# === Example
|
|
7
|
+
#
|
|
8
|
+
# The following example sets up a default set of colors in a 2-column layout,
|
|
9
|
+
# responding to color selections by calling +redraw+ which updates an associated
|
|
10
|
+
# display (not given here):
|
|
11
|
+
#
|
|
12
|
+
# Iup::ColorBar.new do |b|
|
|
13
|
+
# # the following settings define the display
|
|
14
|
+
# b.rastersize = '70x'
|
|
15
|
+
# b.expand = 'vertical'
|
|
16
|
+
# b.num_parts = 2
|
|
17
|
+
# b.show_secondary = 'yes'
|
|
18
|
+
# b.preview_size = 60
|
|
19
|
+
# # this call back responds to single-click color selections by updating display
|
|
20
|
+
# b.select_cb = ->(idx, type){
|
|
21
|
+
# case type
|
|
22
|
+
# when Iup::IUP_PRIMARY
|
|
23
|
+
# canvas.foreground = b.cell(idx)
|
|
24
|
+
# when Iup::IUP_SECONDARY
|
|
25
|
+
# canvas.background = b.cell(idx)
|
|
26
|
+
# end
|
|
27
|
+
# canvas.redraw
|
|
28
|
+
# Iup::DEFAULT
|
|
29
|
+
# }
|
|
30
|
+
# # this call back responds to double-click color selections by updating display
|
|
31
|
+
# b.cell_cb = ->(idx){
|
|
32
|
+
# canvas.foreground cell(idx)
|
|
33
|
+
# canvas.redraw
|
|
34
|
+
# Iup::DEFAULT
|
|
35
|
+
# }
|
|
36
|
+
# # updates display with a switch between primary and secondary colors
|
|
37
|
+
# b.switch_cb = ->(prim_cell, sec_cell){
|
|
38
|
+
# fg_colour = canvas.foreground
|
|
39
|
+
# canvas.foreground = canvas.background
|
|
40
|
+
# canvas.background = fg_colour
|
|
41
|
+
# canvas.redraw
|
|
42
|
+
# Iup::DEFAULT
|
|
43
|
+
# }
|
|
44
|
+
# end
|
|
45
|
+
#
|
|
46
|
+
class ColorBar < Iup::Canvas
|
|
47
|
+
|
|
48
|
+
# Creates a new colorbar instance.
|
|
49
|
+
# If a block is given, the new instance is yielded to it.
|
|
50
|
+
def initialize
|
|
51
|
+
open_controls
|
|
52
|
+
@handle = ControlsLib.IupColorbar
|
|
53
|
+
|
|
54
|
+
# run any provided block on instance, to set up further attributes
|
|
55
|
+
yield self if block_given?
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# -- attributes
|
|
59
|
+
|
|
60
|
+
##
|
|
61
|
+
# :call-seq:
|
|
62
|
+
# bar.cell(n)
|
|
63
|
+
# bar.cell(n, val)
|
|
64
|
+
#
|
|
65
|
+
# Access nth cell color, n in range 0 to num_cells-1.
|
|
66
|
+
define_id_attribute :cell
|
|
67
|
+
|
|
68
|
+
##
|
|
69
|
+
# :attr: num_cells
|
|
70
|
+
# Contains the number of cells, defaults to 16.
|
|
71
|
+
define_attribute :num_cells
|
|
72
|
+
|
|
73
|
+
##
|
|
74
|
+
# :attr_reader: count
|
|
75
|
+
# Same as #num_cells.
|
|
76
|
+
define_reader :count
|
|
77
|
+
|
|
78
|
+
##
|
|
79
|
+
# :attr: num_parts
|
|
80
|
+
# The number of lines or columns, defaults to 1.
|
|
81
|
+
define_attribute :num_parts
|
|
82
|
+
|
|
83
|
+
##
|
|
84
|
+
# :attr: orientation
|
|
85
|
+
# 'horizontal' / 'vertical'
|
|
86
|
+
define_attribute :orientation
|
|
87
|
+
|
|
88
|
+
##
|
|
89
|
+
# :attr: preview_size
|
|
90
|
+
# Size of preview area in pixels.
|
|
91
|
+
define_attribute :preview_size
|
|
92
|
+
|
|
93
|
+
##
|
|
94
|
+
# :attr: show_preview
|
|
95
|
+
# Flag to show preview area or not, values 'yes' / 'no'.
|
|
96
|
+
define_attribute :show_preview
|
|
97
|
+
|
|
98
|
+
##
|
|
99
|
+
# :attr: show_secondary
|
|
100
|
+
# Whether to allow the selection of a secondary color, values 'no' / 'yes'.
|
|
101
|
+
define_attribute :show_secondary
|
|
102
|
+
|
|
103
|
+
##
|
|
104
|
+
# :attr: primary_cell
|
|
105
|
+
# Index of the primary cell, defaults to 0 (black).
|
|
106
|
+
define_attribute :primary_cell
|
|
107
|
+
|
|
108
|
+
##
|
|
109
|
+
# :attr: secondary_cell
|
|
110
|
+
# Index of the secondary cell, defaults to 15 (white).
|
|
111
|
+
define_attribute :secondary_cell
|
|
112
|
+
|
|
113
|
+
##
|
|
114
|
+
# :attr: squared
|
|
115
|
+
# Controls aspect ratio of color cells. Values 'yes' / 'no'.
|
|
116
|
+
define_attribute :squared
|
|
117
|
+
|
|
118
|
+
##
|
|
119
|
+
# :attr: shadowed
|
|
120
|
+
# Controls 3D effect of color cells. Values 'yes' / 'no'.
|
|
121
|
+
define_attribute :shadowed
|
|
122
|
+
|
|
123
|
+
# :section: Callbacks
|
|
124
|
+
|
|
125
|
+
##
|
|
126
|
+
# :attr_writer: cell_cb
|
|
127
|
+
# Callback called when the user double clicks a color cell to change its value.
|
|
128
|
+
# Callback must respond to +call+ and is a 1-argument function: (cell_index),
|
|
129
|
+
# * +cell_index+ - index of clicked cell, between 0 and num_cells-1.
|
|
130
|
+
# Returns a new color (as a string), or nil if no change.
|
|
131
|
+
|
|
132
|
+
# --
|
|
133
|
+
def cell_cb= callback
|
|
134
|
+
unless callback.arity == 1
|
|
135
|
+
raise ArgumentError, 'cell_cb callback must take 1 argument: (cell_index)'
|
|
136
|
+
end
|
|
137
|
+
cb = Proc.new do |ih, cell_index|
|
|
138
|
+
callback.call cell_index
|
|
139
|
+
end
|
|
140
|
+
define_callback cb, 'CELL_CB', :i_s
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
##
|
|
144
|
+
# :attr_writer: extended_cb
|
|
145
|
+
# Callback called when the user right click a cell with the Shift key pressed
|
|
146
|
+
# Callback must respond to +call+ is a 1-argument function: (cell_index).
|
|
147
|
+
# * +cell_index+ - index of clicked cell, between 0 and num_cells-1.
|
|
148
|
+
# If returns Iup::DEFAULT, cell is redrawn; if returns Iup::IGNORE, cell
|
|
149
|
+
# is not redrawn.
|
|
150
|
+
|
|
151
|
+
# --
|
|
152
|
+
def extended_cb= callback
|
|
153
|
+
unless callback.arity == 1
|
|
154
|
+
raise ArgumentError, 'extended_cb callback must take 1 argument: (cell_index)'
|
|
155
|
+
end
|
|
156
|
+
cb = Proc.new do |ih, cell_index|
|
|
157
|
+
callback.call cell_index
|
|
158
|
+
end
|
|
159
|
+
define_callback cb, 'EXTENDED_CB', :i_i
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
##
|
|
163
|
+
# :attr_writer: select_cb
|
|
164
|
+
# Callback called when a color is selected.
|
|
165
|
+
# The primary color is selected with the left mouse button, and, if
|
|
166
|
+
# present, secondary is selected with the right mouse button.
|
|
167
|
+
# Callback must respond to +call+ and is a 2-argument function: (cell_index, type):
|
|
168
|
+
# * +cell_index+ - index of selected color
|
|
169
|
+
# * +type+ - of color, see {type constants}[../Iup.html#ColorBar+select_cb+type]
|
|
170
|
+
|
|
171
|
+
# --
|
|
172
|
+
def select_cb= callback
|
|
173
|
+
unless callback.arity == 2
|
|
174
|
+
raise ArgumentError, 'select_cb callback must take 2 arguments: (cell_index, type)'
|
|
175
|
+
end
|
|
176
|
+
cb = Proc.new do |ih, cell_index, type|
|
|
177
|
+
callback.call cell_index, type
|
|
178
|
+
end
|
|
179
|
+
define_callback cb, 'SELECT_CB', :ii_i
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
##
|
|
183
|
+
# :attr_writer: switch_cb
|
|
184
|
+
# Callback called when the user double clicks the preview area outside the
|
|
185
|
+
# preview cells to switch the primary and secondary selections. It is
|
|
186
|
+
# only called if SHOW_SECONDARY=YES.
|
|
187
|
+
# Callback must respond to +call+ and takes 2 arguments: (prim_cell, sec_cell):
|
|
188
|
+
# * +prim_cell+ - index of primary cell
|
|
189
|
+
# * +sec_cell+ - index of secondary cell
|
|
190
|
+
|
|
191
|
+
# --
|
|
192
|
+
def switch_cb= callback
|
|
193
|
+
unless callback.arity == 2
|
|
194
|
+
raise ArgumentError, 'switch_cb callback must take 2 arguments: (prim_cell, sec_cell)'
|
|
195
|
+
end
|
|
196
|
+
cb = Proc.new do |ih, cell_index, type|
|
|
197
|
+
callback.call cell_index, type
|
|
198
|
+
end
|
|
199
|
+
define_callback cb, 'SWITCH_CB', :ii_i
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# :section: ColorBar select_cb type
|
|
204
|
+
|
|
205
|
+
# Identifies color type as the primary color.
|
|
206
|
+
IUP_PRIMARY = -1
|
|
207
|
+
# Identifies color type as the secondary color.
|
|
208
|
+
IUP_SECONDARY = -2
|
|
209
|
+
|
|
210
|
+
# :section:
|
|
211
|
+
end
|
|
212
|
+
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# Shows a modal dialog to select a color.
|
|
4
|
+
#
|
|
5
|
+
# * +x+, +y+ - optional coordinates to place the dialog
|
|
6
|
+
#
|
|
7
|
+
# Returns r/g/b triple of selected color, or nil if "cancel" clicked.
|
|
8
|
+
#
|
|
9
|
+
# r, g, b = Iup.get_color(150, 150)
|
|
10
|
+
#
|
|
11
|
+
# Also see: ColorDialog
|
|
12
|
+
#
|
|
13
|
+
def self.get_color x=0, y=0
|
|
14
|
+
r = FFI::MemoryPointer.new(:int, 1, 0)
|
|
15
|
+
g = FFI::MemoryPointer.new(:int, 1, 0)
|
|
16
|
+
b = FFI::MemoryPointer.new(:int, 1, 0)
|
|
17
|
+
code = IupLib.IupGetColor x, y, r, g, b
|
|
18
|
+
if code == 0
|
|
19
|
+
return nil
|
|
20
|
+
else
|
|
21
|
+
return r.read_int, g.read_int, b.read_int
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# A predefined modal dialog used for selecting a color.
|
|
26
|
+
#
|
|
27
|
+
# === Example
|
|
28
|
+
#
|
|
29
|
+
# dlg = Iup::ColorDialog.new do |d|
|
|
30
|
+
# d.title = "select a new color"
|
|
31
|
+
# end
|
|
32
|
+
# dlg.popup
|
|
33
|
+
# p dlg.value # retrieve the selected color
|
|
34
|
+
#
|
|
35
|
+
# Also see: Iup.get_color
|
|
36
|
+
#
|
|
37
|
+
class ColorDialog < Iup::Dialog
|
|
38
|
+
|
|
39
|
+
# Creates a dialog, using the optional block to set its attributes.
|
|
40
|
+
def initialize &block
|
|
41
|
+
@handle = IupLib.IupColorDlg
|
|
42
|
+
|
|
43
|
+
yield self if block_given?
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# :section: Callbacks
|
|
47
|
+
|
|
48
|
+
##
|
|
49
|
+
# :attr_writer: colorupdate_cb
|
|
50
|
+
#
|
|
51
|
+
# Action generated when the color is updated in the dialog.
|
|
52
|
+
# Callback must respond to +call+ and take no arguments.
|
|
53
|
+
|
|
54
|
+
# --
|
|
55
|
+
def colorupdate_cb= callback
|
|
56
|
+
unless callback.arity.zero?
|
|
57
|
+
raise ArgumentError, 'colorupdate_cb callback must take 0 arguments'
|
|
58
|
+
end
|
|
59
|
+
cb = Proc.new do |ih|
|
|
60
|
+
callback.call
|
|
61
|
+
end
|
|
62
|
+
define_callback cb, 'COLORUPDATE_CB', :plain_v
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# :section:
|
|
66
|
+
|
|
67
|
+
# -- attributes
|
|
68
|
+
|
|
69
|
+
##
|
|
70
|
+
# :attr: alpha
|
|
71
|
+
# If defined, enables alpha selection in dialog.
|
|
72
|
+
# Returns value if user pressed 'OK'.
|
|
73
|
+
define_attribute :alpha
|
|
74
|
+
|
|
75
|
+
##
|
|
76
|
+
# :attr: colortable
|
|
77
|
+
# "m;n;..." gives a list of values for the palette.
|
|
78
|
+
define_attribute :colortable
|
|
79
|
+
|
|
80
|
+
##
|
|
81
|
+
# :attr: showalpha
|
|
82
|
+
# If set, shows the color table. Values 'yes' / 'no'.
|
|
83
|
+
define_attribute :showalpha
|
|
84
|
+
|
|
85
|
+
##
|
|
86
|
+
# :attr: showcolortable
|
|
87
|
+
# If set, shows the color table. Values 'yes' / 'no'.
|
|
88
|
+
define_attribute :showcolortable
|
|
89
|
+
|
|
90
|
+
##
|
|
91
|
+
# :attr: showhelp
|
|
92
|
+
# Shows a help button if +help_cb+ defined. Values 'yes' / 'no'.
|
|
93
|
+
define_attribute :showhelp
|
|
94
|
+
|
|
95
|
+
##
|
|
96
|
+
# :attr: showhex
|
|
97
|
+
# If set, shows a hexadecimal representation of color. Values 'yes' / 'no'.
|
|
98
|
+
define_attribute :showhex
|
|
99
|
+
|
|
100
|
+
##
|
|
101
|
+
# :attr_reader: status
|
|
102
|
+
# Returns '1' if 'OK' pressed, or null.
|
|
103
|
+
define_reader :status
|
|
104
|
+
|
|
105
|
+
##
|
|
106
|
+
# :attr: value
|
|
107
|
+
# Initial value for dialog, and return value if 'OK' pressed, as 'r g b' or 'r g b a'.
|
|
108
|
+
define_attribute :value
|
|
109
|
+
|
|
110
|
+
##
|
|
111
|
+
# :attr: valuehex
|
|
112
|
+
# Initial value for dialog, and return value if 'OK' pressed, as 'rrggbb'.
|
|
113
|
+
define_attribute :valuehex
|
|
114
|
+
|
|
115
|
+
##
|
|
116
|
+
# :attr: valuehsi
|
|
117
|
+
# Initial value for dialog, and return value if 'OK' pressed, as 'H S I'.
|
|
118
|
+
define_attribute :valuehsi
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# Standard callback method for when a mouse button is pressed or released.
|
|
4
|
+
module ButtonCallback
|
|
5
|
+
|
|
6
|
+
# :section: Callbacks
|
|
7
|
+
|
|
8
|
+
##
|
|
9
|
+
# :attr_writer: button_cb
|
|
10
|
+
#
|
|
11
|
+
# Action generated when any mouse button is pressed or released.
|
|
12
|
+
# Callback must respond to +call+ and accept 5 arguments (button, state, x,
|
|
13
|
+
# y, status)
|
|
14
|
+
# * +button+ - the number of the button that changed, one of: BUTTON1 (left), BUTTON2 (middle), BUTTON3 (right)
|
|
15
|
+
# * +state+ - 1 for 'pressed', 0 for 'released'
|
|
16
|
+
# * +x+ - x-coordinate
|
|
17
|
+
# * +y+ - y-coordinate
|
|
18
|
+
# * +status+ - status of the mouse buttons and some keyboard keys at the moment the event is generated.
|
|
19
|
+
|
|
20
|
+
#--
|
|
21
|
+
def button_cb= callback
|
|
22
|
+
unless callback.arity == 5
|
|
23
|
+
raise ArgumentError, 'button_cb callback must take 5 arguments: (button, state, x, y, status)'
|
|
24
|
+
end
|
|
25
|
+
cb = Proc.new do |ih, b, p, x, y, status|
|
|
26
|
+
callback.call b.chr, p, x, y, status
|
|
27
|
+
end
|
|
28
|
+
define_callback cb, 'BUTTON_CB', :iiiis_i
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
|