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,168 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# Convenience function to show a modal dialog to select a filename.
|
|
4
|
+
#
|
|
5
|
+
# * +filter+ - path + filter for files to show
|
|
6
|
+
#
|
|
7
|
+
# Returns the status code and selected filename:
|
|
8
|
+
# status is an integer, 1 for new file, 0 for existing file/directory, or -1
|
|
9
|
+
# for cancelled.
|
|
10
|
+
#
|
|
11
|
+
# Also see: FileDialog
|
|
12
|
+
#
|
|
13
|
+
# For example, select a filename ending in ".txt" from current directory.
|
|
14
|
+
#
|
|
15
|
+
# code, file = Iup.get_file('./*.txt')
|
|
16
|
+
#
|
|
17
|
+
def self.get_file filter=''
|
|
18
|
+
file = ' '*(256-filter.size) + filter
|
|
19
|
+
code = IupLib.IupGetFile(file)
|
|
20
|
+
case code
|
|
21
|
+
when 0, 1
|
|
22
|
+
filename = file[0...file.index("\0")]
|
|
23
|
+
return code, filename
|
|
24
|
+
else
|
|
25
|
+
return code, ''
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# A predefined modal dialog for selecting files or a directory.
|
|
30
|
+
#
|
|
31
|
+
# === Example
|
|
32
|
+
#
|
|
33
|
+
# The following opens a "save file" dialog, filtered on Ruby files.
|
|
34
|
+
#
|
|
35
|
+
# filedlg = Iup::FileDialog.new do |d|
|
|
36
|
+
# d.dialogtype = 'save'
|
|
37
|
+
# d.title = 'File Save'
|
|
38
|
+
# d.filter = '*.rb'
|
|
39
|
+
# d.filterinfo = 'Ruby Files'
|
|
40
|
+
# end
|
|
41
|
+
# filedlg.popup(300, 300)
|
|
42
|
+
#
|
|
43
|
+
# Note that +popup+ must be used to show the dialog.
|
|
44
|
+
#
|
|
45
|
+
# Also see: Iup.get_file
|
|
46
|
+
#
|
|
47
|
+
class FileDialog < Iup::Dialog
|
|
48
|
+
|
|
49
|
+
# Creates a new dialog.
|
|
50
|
+
# If a block is given, the new instance is yielded to it.
|
|
51
|
+
def initialize
|
|
52
|
+
@handle = IupLib.IupFileDlg
|
|
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
|
+
# :attr: allownew
|
|
62
|
+
# If set, indicates if non-existent filenames are accepted.
|
|
63
|
+
# Values as 'yes' / 'no' - defaults to 'no'.
|
|
64
|
+
define_attribute :allownew
|
|
65
|
+
|
|
66
|
+
##
|
|
67
|
+
# :attr: dialogtype
|
|
68
|
+
# 'open' / 'save' / 'dir'
|
|
69
|
+
define_attribute :dialogtype
|
|
70
|
+
|
|
71
|
+
##
|
|
72
|
+
# :attr: directory
|
|
73
|
+
# Initial directory
|
|
74
|
+
define_attribute :directory
|
|
75
|
+
|
|
76
|
+
##
|
|
77
|
+
# :attr: extfilter
|
|
78
|
+
# Defines filters, e.g. "Text files\|\*.txt;\*.doc\|Image files\|\*.gif;\*.jpg;\*.bmp\|",
|
|
79
|
+
# has priority over +filterinfo+ and +filter+.
|
|
80
|
+
define_attribute :extfilter
|
|
81
|
+
|
|
82
|
+
##
|
|
83
|
+
# :attr: file
|
|
84
|
+
# Name of file. Will be used instead of +dictionary+ if it contains a complete path.
|
|
85
|
+
define_attribute :file
|
|
86
|
+
|
|
87
|
+
##
|
|
88
|
+
# :attr: filter
|
|
89
|
+
# Filter to use, e.g. "\*.C;\*.LED;test.\*".
|
|
90
|
+
define_attribute :filter
|
|
91
|
+
|
|
92
|
+
##
|
|
93
|
+
# :attr: filterinfo
|
|
94
|
+
# Information about the +filter+, e.g. "C files".
|
|
95
|
+
define_attribute :filterinfo
|
|
96
|
+
|
|
97
|
+
##
|
|
98
|
+
# :attr: filterused
|
|
99
|
+
# n, index of filter from +extfilter+ that was used.
|
|
100
|
+
# Index counts from 1.
|
|
101
|
+
define_attribute :filterused
|
|
102
|
+
|
|
103
|
+
##
|
|
104
|
+
# :attr: multiplefiles
|
|
105
|
+
# 'no' / 'yes', set to allow selection of multiple files.
|
|
106
|
+
define_attribute :multiplefiles
|
|
107
|
+
|
|
108
|
+
##
|
|
109
|
+
# :attr: nochangedir
|
|
110
|
+
# 'yes' / 'no', if set, restores current directory after dialog is closed.
|
|
111
|
+
define_attribute :nochangedir
|
|
112
|
+
|
|
113
|
+
##
|
|
114
|
+
# :attr: nooverwriteprompt
|
|
115
|
+
# 'no' / 'yes', if set, prompts before overwriting existing files.
|
|
116
|
+
define_attribute :nooverwriteprompt
|
|
117
|
+
|
|
118
|
+
##
|
|
119
|
+
# :attr: showhidden
|
|
120
|
+
# 'no' / 'yes', if set, shows hidden files.
|
|
121
|
+
define_attribute :showhidden
|
|
122
|
+
|
|
123
|
+
##
|
|
124
|
+
# :attr: showpreview
|
|
125
|
+
# 'no' / 'yes', if set, shows a preview area for file.
|
|
126
|
+
define_attribute :showpreview
|
|
127
|
+
|
|
128
|
+
##
|
|
129
|
+
# :attr_reader: status
|
|
130
|
+
#
|
|
131
|
+
# Returns an integer: 1 for new file, 0 for existing file/directory, or -1 for cancelled.
|
|
132
|
+
|
|
133
|
+
# --
|
|
134
|
+
def status
|
|
135
|
+
status = IupLib.IupGetAttribute(@handle, 'STATUS').first
|
|
136
|
+
status.to_i
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
##
|
|
140
|
+
# :attr_reader: value
|
|
141
|
+
# Name of file(s) selected.
|
|
142
|
+
define_reader :value
|
|
143
|
+
|
|
144
|
+
# :section: Callbacks
|
|
145
|
+
|
|
146
|
+
##
|
|
147
|
+
# :attr_writer: file_cb
|
|
148
|
+
#
|
|
149
|
+
# Sets callback for when a file is selected.
|
|
150
|
+
# callback must respond to +call+ and take two arguments: (filename, status)
|
|
151
|
+
# * +filename+ - filename of selected file
|
|
152
|
+
# * +status+ -
|
|
153
|
+
|
|
154
|
+
# --
|
|
155
|
+
def file_cb= callback
|
|
156
|
+
unless callback.arity == 2
|
|
157
|
+
raise ArgumentError, 'file_cb callback must take 2 arguments, a filename, and status'
|
|
158
|
+
end
|
|
159
|
+
cb = Proc.new do |ih, fn_ptr, st_ptr|
|
|
160
|
+
fn = FFI::Pointer.new(fn_ptr).read_string
|
|
161
|
+
st = FFI::Pointer.new(st_ptr).read_string
|
|
162
|
+
callback.call fn, st
|
|
163
|
+
end
|
|
164
|
+
define_callback cb, 'FILE_CB', :ss_i
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
data/lib/wrapped/fill.rb
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# Dynamically fills empty space. Its parent _must_ be an HBox or VBox.
|
|
4
|
+
#
|
|
5
|
+
class Fill < Iup::Widget
|
|
6
|
+
|
|
7
|
+
# Creates a new instance.
|
|
8
|
+
# Note that attributes must be set separately, not through a block.
|
|
9
|
+
def initialize
|
|
10
|
+
@handle = IupLib.IupFill
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
##
|
|
14
|
+
# :attr_reader: expand
|
|
15
|
+
# 'horizontal' if in an HBox, or 'vertical' if in a VBox.
|
|
16
|
+
define_reader :expand
|
|
17
|
+
|
|
18
|
+
##
|
|
19
|
+
# :attr_reader: position
|
|
20
|
+
# returns position in pixels within client window as "x,y".
|
|
21
|
+
define_reader :position
|
|
22
|
+
|
|
23
|
+
##
|
|
24
|
+
# :attr: rastersize
|
|
25
|
+
# Size of the widget, in pixels, value as "widthxheight".
|
|
26
|
+
define_attribute :rastersize
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# A predefined modal dialog to select a font.
|
|
4
|
+
#
|
|
5
|
+
# === Example
|
|
6
|
+
#
|
|
7
|
+
# dlg = Iup::FontDialog.new do
|
|
8
|
+
# d.title = "Select a new font"
|
|
9
|
+
# d.font = "Times, bold 18"
|
|
10
|
+
# end
|
|
11
|
+
# dlg.popup
|
|
12
|
+
#
|
|
13
|
+
# Note that +popup+ must be used to show the dialog.
|
|
14
|
+
#
|
|
15
|
+
class FontDialog < Iup::Widget
|
|
16
|
+
|
|
17
|
+
# Creates a new dialog.
|
|
18
|
+
# If a block is given, the new instance is yielded to it.
|
|
19
|
+
def initialize
|
|
20
|
+
@handle = IupLib.IupFontDlg
|
|
21
|
+
|
|
22
|
+
yield self if block_given?
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Shows the dialog at position x, y.
|
|
26
|
+
# * +x+ - x-coordinate to use, or one of {show constants}[../Iup.html#Dialog+show+position]
|
|
27
|
+
# * +y+ - y-coordinate to use, or one of {show constants}[../Iup.html#Dialog+show+position]
|
|
28
|
+
def popup x=0, y=0
|
|
29
|
+
IupLib.IupPopup @handle, x, y
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# -- attributes
|
|
33
|
+
|
|
34
|
+
##
|
|
35
|
+
# :attr: parentdialog
|
|
36
|
+
# This dialog will be always in front of the parent dialog.
|
|
37
|
+
# If the parent is minimized, this dialog is automatically minimized.
|
|
38
|
+
# *Important* Closing the parent will also close the child, but the
|
|
39
|
+
# child dialog's CLOSE_CB method will not be called.
|
|
40
|
+
|
|
41
|
+
# --
|
|
42
|
+
def parentdialog
|
|
43
|
+
attribute_reference('PARENTDIALOG', Dialog, nil)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def parentdialog= parent # :nodoc:
|
|
47
|
+
attribute_reference('PARENTDIALOG', Dialog, parent)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
##
|
|
51
|
+
# :attr: previewtext
|
|
52
|
+
# The text to use for preview of font selection.
|
|
53
|
+
define_attribute :previewtext
|
|
54
|
+
|
|
55
|
+
##
|
|
56
|
+
# :attr_reader: status
|
|
57
|
+
# returns '1' if 'OK' pressed, or null
|
|
58
|
+
define_reader :status
|
|
59
|
+
|
|
60
|
+
##
|
|
61
|
+
# :attr: title
|
|
62
|
+
# Title text for the message dialog.
|
|
63
|
+
define_attribute :title
|
|
64
|
+
|
|
65
|
+
##
|
|
66
|
+
# :attr: value
|
|
67
|
+
# Initial value of font for dialog, and return value if 'OK' pressed.
|
|
68
|
+
define_attribute :value
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# A frame contains a child widget and displays it with a border.
|
|
4
|
+
# Optionally, the frame can have a text title.
|
|
5
|
+
#
|
|
6
|
+
# === Example
|
|
7
|
+
#
|
|
8
|
+
# Example placing a text label on widgets placed into a HBox:
|
|
9
|
+
#
|
|
10
|
+
# Iup::Frame.new(hbox) do |f|
|
|
11
|
+
# f.title = 'ALIGNMENT=ALEFT, GAP=10'
|
|
12
|
+
# end
|
|
13
|
+
#
|
|
14
|
+
class Frame < Iup::Widget
|
|
15
|
+
|
|
16
|
+
# Creates an instance of the frame.
|
|
17
|
+
# If a block is given, the new instance is yielded to it.
|
|
18
|
+
# * +widget+ - the child widget to display.
|
|
19
|
+
def initialize widget
|
|
20
|
+
@handle = IupLib.IupFrame(widget.handle)
|
|
21
|
+
|
|
22
|
+
# run any provided block on instance, to set up further attributes
|
|
23
|
+
yield self if block_given?
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# -- attributes
|
|
27
|
+
|
|
28
|
+
##
|
|
29
|
+
# :attr_reader: clientoffset
|
|
30
|
+
# Returns current offset of frame in its client as "widthxheight".
|
|
31
|
+
define_reader :clientoffset
|
|
32
|
+
|
|
33
|
+
##
|
|
34
|
+
# :attr_reader: clientsize
|
|
35
|
+
# Returns current size of frame as "widthxheight".
|
|
36
|
+
define_reader :clientsize
|
|
37
|
+
|
|
38
|
+
##
|
|
39
|
+
# :attr: expand
|
|
40
|
+
# Allows frame to fill available space in indicated direction.
|
|
41
|
+
# Values 'no' / 'horizontal' / 'vertical' / 'yes'.
|
|
42
|
+
define_attribute :expand
|
|
43
|
+
|
|
44
|
+
##
|
|
45
|
+
# :attr_reader: position
|
|
46
|
+
# returns position in pixels within client window as "x,y".
|
|
47
|
+
define_reader :position
|
|
48
|
+
|
|
49
|
+
##
|
|
50
|
+
# :attr: rastersize
|
|
51
|
+
# Size of the frame, in pixels, value as "widthxheight".
|
|
52
|
+
define_attribute :rastersize
|
|
53
|
+
|
|
54
|
+
##
|
|
55
|
+
# :attr_reader: screenposition
|
|
56
|
+
# returns position in pixels on screen as "x,y".
|
|
57
|
+
define_reader :screenposition
|
|
58
|
+
|
|
59
|
+
##
|
|
60
|
+
# :attr: sunken
|
|
61
|
+
# For frame with no title, gives a sunken appearance if set: values as 'yes' / 'no'.
|
|
62
|
+
define_attribute :sunken
|
|
63
|
+
|
|
64
|
+
##
|
|
65
|
+
# :attr: title
|
|
66
|
+
# \Text displayed as frame title.
|
|
67
|
+
define_attribute :title
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# A container which arranges its widgets in a left-to-right, top-to-bottom order
|
|
4
|
+
# to form a grid-like arrangement.
|
|
5
|
+
#
|
|
6
|
+
# === Example
|
|
7
|
+
#
|
|
8
|
+
# The following example sets up a 2x2 grid of labels, each centered with a
|
|
9
|
+
# small gap between the columns:
|
|
10
|
+
#
|
|
11
|
+
# box = Iup::GridBox.new(lbl1, lbl2, lbl3, lbl4) do |b|
|
|
12
|
+
# b.sizelin = 1 # the second line is used for calculating spacing
|
|
13
|
+
# b.numdiv = 2 # arranges labels with 2 columns
|
|
14
|
+
# b.alignmentlin = 'acenter'
|
|
15
|
+
# b.gapcol = 5
|
|
16
|
+
# end
|
|
17
|
+
#
|
|
18
|
+
# Also see: HBox, VBox
|
|
19
|
+
#
|
|
20
|
+
class GridBox < Iup::Widget
|
|
21
|
+
include DynamicFillMethods
|
|
22
|
+
|
|
23
|
+
# Creates an instance of the gridbox.
|
|
24
|
+
# If a block is given, the new instance is yielded to it.
|
|
25
|
+
#
|
|
26
|
+
# * +widgets+ -one or more child widgets
|
|
27
|
+
#
|
|
28
|
+
def initialize *widgets
|
|
29
|
+
@handle = IupLib.IupGridBox(*widget_list(widgets))
|
|
30
|
+
|
|
31
|
+
# run any provided block on instance, to set up further attributes
|
|
32
|
+
yield self if block_given?
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# -- attributes
|
|
36
|
+
|
|
37
|
+
# :call-seq:
|
|
38
|
+
# gridbox.alignmentcol() # Reads value of "ALIGNMENTCOL"
|
|
39
|
+
# grid.alignmentcol(val) # Sets "ALIGNMENTCOL" to val
|
|
40
|
+
# grid.alignmentcol(n, val) # Sets alignment of column n to val
|
|
41
|
+
#
|
|
42
|
+
# Alignment values are 'ALEFT' / 'ACENTER' / 'ARIGHT'.
|
|
43
|
+
def alignmentcol val=nil, val2=nil
|
|
44
|
+
if val.nil?
|
|
45
|
+
IupLib.IupGetAttribute(@handle, 'ALIGNMENTCOL').first
|
|
46
|
+
elsif val2.nil?
|
|
47
|
+
IupLib.IupSetAttribute @handle, 'ALIGNMENTCOL', val.to_s
|
|
48
|
+
else
|
|
49
|
+
IupLib.IupSetAttribute @handle, "ALIGNMENTCOL#{val}", val2.to_s
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# :call-seq:
|
|
54
|
+
# gridbox.alignmentlin() # Reads value of "ALIGNMENTLIN"
|
|
55
|
+
# grid.alignmentlin(val) # Sets "ALIGNMENTLIN" to val
|
|
56
|
+
# grid.alignmentlin(n, val) # Sets alignment of line n to val
|
|
57
|
+
#
|
|
58
|
+
# Alignment values are 'ATOP' / 'ACENTER' / 'ABOTTOM'.
|
|
59
|
+
def alignmentlin val=nil, val2=nil
|
|
60
|
+
if val.nil?
|
|
61
|
+
IupLib.IupGetAttribute(@handle, 'ALIGNMENTLIN').first
|
|
62
|
+
elsif val2.nil?
|
|
63
|
+
IupLib.IupSetAttribute @handle, 'ALIGNMENTLIN', val.to_s
|
|
64
|
+
else
|
|
65
|
+
IupLib.IupSetAttribute @handle, "ALIGNMENTLIN#{val}", val2.to_s
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
##
|
|
70
|
+
# :attr: cgapcol
|
|
71
|
+
# n, horizontal space in characters between columns.
|
|
72
|
+
define_attribute :cgapcol
|
|
73
|
+
|
|
74
|
+
##
|
|
75
|
+
# :attr: cgaplin
|
|
76
|
+
# n, vertical space in characters between lines.
|
|
77
|
+
define_attribute :cgaplin
|
|
78
|
+
|
|
79
|
+
##
|
|
80
|
+
# :attr_reader: clientoffset
|
|
81
|
+
# returns current offset of box in its client as "widthxheight".
|
|
82
|
+
define_reader :clientoffset
|
|
83
|
+
|
|
84
|
+
##
|
|
85
|
+
# :attr_reader: clientsize
|
|
86
|
+
# returns current size of box as "widthxheight".
|
|
87
|
+
define_reader :clientsize
|
|
88
|
+
|
|
89
|
+
##
|
|
90
|
+
# :attr: cmargin
|
|
91
|
+
# Margin in x and y directions in characters, value as "mxn".
|
|
92
|
+
define_attribute :cmargin
|
|
93
|
+
|
|
94
|
+
##
|
|
95
|
+
# :attr: expand
|
|
96
|
+
# Allows container to fill available space in indicated direction.
|
|
97
|
+
# Values 'no' / 'horizontal' / 'vertical' / 'yes'.
|
|
98
|
+
define_attribute :expand
|
|
99
|
+
|
|
100
|
+
##
|
|
101
|
+
# :attr: expandchildren
|
|
102
|
+
# Set to allow children to expand fully,
|
|
103
|
+
# values as 'yes' / 'no' / 'horizontal' / 'vertical'.
|
|
104
|
+
define_attribute :expandchildren
|
|
105
|
+
|
|
106
|
+
##
|
|
107
|
+
# :attr: fittochildren
|
|
108
|
+
# 'column' / 'line', n -> force column/line n to fit largest element in that column/line.
|
|
109
|
+
define_attribute :fittochildren
|
|
110
|
+
|
|
111
|
+
##
|
|
112
|
+
# :attr: gapcol
|
|
113
|
+
# Horizontal space in pixels between columns.
|
|
114
|
+
define_attribute :gapcol
|
|
115
|
+
|
|
116
|
+
##
|
|
117
|
+
# :attr: gaplin
|
|
118
|
+
# Vertical space in pixels between lines.
|
|
119
|
+
define_attribute :gaplin
|
|
120
|
+
|
|
121
|
+
##
|
|
122
|
+
# :attr: homogeneouscol
|
|
123
|
+
# Forces all columns to have same horizontal space.
|
|
124
|
+
# Values as 'yes' / 'no'.
|
|
125
|
+
define_attribute :homogeneouscol
|
|
126
|
+
|
|
127
|
+
##
|
|
128
|
+
# :attr: homogeneouslin
|
|
129
|
+
# Forces all lines to have same vertical space.
|
|
130
|
+
# Values as 'yes' / 'no'.
|
|
131
|
+
define_attribute :homogeneouslin
|
|
132
|
+
|
|
133
|
+
##
|
|
134
|
+
# :attr: margin
|
|
135
|
+
# Margin in x and y directions in pixels, value as "mxn".
|
|
136
|
+
define_attribute :margin
|
|
137
|
+
|
|
138
|
+
##
|
|
139
|
+
# :attr: normalsize
|
|
140
|
+
# Set to make natural size of children same,
|
|
141
|
+
# values as 'yes' / 'no' / 'horizontal' / 'vertical'.
|
|
142
|
+
define_attribute :normalizesize
|
|
143
|
+
|
|
144
|
+
##
|
|
145
|
+
# :attr_reader: numcol
|
|
146
|
+
# returns number of columns.
|
|
147
|
+
define_reader :numcol
|
|
148
|
+
|
|
149
|
+
##
|
|
150
|
+
# :attr: numdiv
|
|
151
|
+
# 'auto' / n, controls number of divisions in direction as determined by
|
|
152
|
+
# +orientation+.
|
|
153
|
+
define_attribute :numdiv
|
|
154
|
+
|
|
155
|
+
##
|
|
156
|
+
# :attr_reader: numlin
|
|
157
|
+
# returns number of lines.
|
|
158
|
+
define_reader :numlin
|
|
159
|
+
|
|
160
|
+
##
|
|
161
|
+
# :attr: orientation
|
|
162
|
+
# Controls distribution of children, in lines or columns.
|
|
163
|
+
# Value as 'horizontal' / 'vertical'.
|
|
164
|
+
define_attribute :orientation
|
|
165
|
+
|
|
166
|
+
##
|
|
167
|
+
# :attr_reader: position
|
|
168
|
+
# returns position in pixels within client window as "x,y".
|
|
169
|
+
define_reader :position
|
|
170
|
+
|
|
171
|
+
##
|
|
172
|
+
# :attr: rastersize
|
|
173
|
+
# Size of the container, in pixels, value as "widthxheight".
|
|
174
|
+
define_attribute :rastersize
|
|
175
|
+
|
|
176
|
+
##
|
|
177
|
+
# :attr: sizecol
|
|
178
|
+
# Index of column to use for calculating height of lines.
|
|
179
|
+
# Note: make sure column is within range, else can crash.
|
|
180
|
+
define_attribute :sizecol
|
|
181
|
+
|
|
182
|
+
##
|
|
183
|
+
# :attr: sizelin
|
|
184
|
+
# Index of line to use for calculating width of columns.
|
|
185
|
+
# Note: make sure line is within range, else can crash.
|
|
186
|
+
define_attribute :sizelin
|
|
187
|
+
end
|
|
188
|
+
end
|
data/lib/wrapped/hbox.rb
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# A container for one or more child widgets, arranged in a horizontal row.
|
|
4
|
+
#
|
|
5
|
+
# === Example
|
|
6
|
+
#
|
|
7
|
+
# The following example puts a label beside a button:
|
|
8
|
+
#
|
|
9
|
+
# box = Iup::HBox.new(label, button) do |b|
|
|
10
|
+
# b.gap = 10
|
|
11
|
+
# b.margin = '5x5'
|
|
12
|
+
# b.expand = :yes
|
|
13
|
+
# end
|
|
14
|
+
#
|
|
15
|
+
# Also see: Fill, VBox
|
|
16
|
+
#
|
|
17
|
+
class HBox < Iup::Widget
|
|
18
|
+
include DynamicFillMethods
|
|
19
|
+
|
|
20
|
+
# Creates an instance of the hbox.
|
|
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.IupHbox(*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: alignment
|
|
36
|
+
# horizontal alignment of children, 'atop' / 'acenter' / 'abottom'
|
|
37
|
+
define_attribute :alignment
|
|
38
|
+
|
|
39
|
+
##
|
|
40
|
+
# :attr_reader: clientoffset
|
|
41
|
+
# returns current offset of box in its client as "widthxheight".
|
|
42
|
+
define_reader :clientoffset
|
|
43
|
+
|
|
44
|
+
##
|
|
45
|
+
# :attr_reader: clientsize
|
|
46
|
+
# returns current size of box as "widthxheight".
|
|
47
|
+
define_reader :clientsize
|
|
48
|
+
|
|
49
|
+
##
|
|
50
|
+
# :attr: expand
|
|
51
|
+
# Allows container to fill available space in indicated direction.
|
|
52
|
+
# Values 'no' / 'horizontal' / 'vertical' / 'yes'.
|
|
53
|
+
define_attribute :expand
|
|
54
|
+
|
|
55
|
+
##
|
|
56
|
+
# :attr: expandchildren
|
|
57
|
+
# Set to allow children to expand in vertical direction, values as 'yes' / 'no'.
|
|
58
|
+
define_attribute :expandchildren
|
|
59
|
+
|
|
60
|
+
##
|
|
61
|
+
# :attr: gap
|
|
62
|
+
# Number of pixels between children, default value of 0.
|
|
63
|
+
define_attribute :gap
|
|
64
|
+
|
|
65
|
+
##
|
|
66
|
+
# :attr: homogeneous
|
|
67
|
+
# Set to force all children to get equal horizontal space, values as 'yes' / 'no'.
|
|
68
|
+
define_attribute :homogeneous
|
|
69
|
+
|
|
70
|
+
##
|
|
71
|
+
# :attr: margin
|
|
72
|
+
# Margin in x and y directions, value as "mxn".
|
|
73
|
+
define_attribute :margin
|
|
74
|
+
|
|
75
|
+
##
|
|
76
|
+
# :attr: normalsize
|
|
77
|
+
# Set to make natural size of children same, values as 'yes' / 'no'.
|
|
78
|
+
define_attribute :normalizesize
|
|
79
|
+
|
|
80
|
+
##
|
|
81
|
+
# :attr_reader: position
|
|
82
|
+
# returns position in pixels within client window as "x,y".
|
|
83
|
+
define_reader :position
|
|
84
|
+
|
|
85
|
+
##
|
|
86
|
+
# :attr: rastersize
|
|
87
|
+
# Size of the container, in pixels, value as "widthxheight".
|
|
88
|
+
define_attribute :rastersize
|
|
89
|
+
end
|
|
90
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# Defines attributes for widgets which contain images.
|
|
4
|
+
#
|
|
5
|
+
module ImageAttributes
|
|
6
|
+
include AttributeReference
|
|
7
|
+
|
|
8
|
+
##
|
|
9
|
+
# :attr: image
|
|
10
|
+
#
|
|
11
|
+
# The image to display, based on an image or image name.
|
|
12
|
+
# This can use an actual image object, or the name of an image
|
|
13
|
+
# from +IupImageLib+.
|
|
14
|
+
|
|
15
|
+
# --
|
|
16
|
+
def image
|
|
17
|
+
attribute_reference('IMAGE', ImageWidget, nil)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def image= val #:nodoc:
|
|
21
|
+
attribute_reference('IMAGE', ImageWidget, val)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
##
|
|
25
|
+
# :attr: iminactive
|
|
26
|
+
#
|
|
27
|
+
# The image to display when inactive, based on an image or image name.
|
|
28
|
+
# This can use an actual image object, or the name of an image
|
|
29
|
+
# from +IupImageLib+.
|
|
30
|
+
|
|
31
|
+
# --
|
|
32
|
+
def iminactive
|
|
33
|
+
attribute_reference('IMINACTION', ImageWidget, nil)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def iminactive= val # :nodoc:
|
|
37
|
+
attribute_reference('IMINACTION', ImageWidget, val)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
##
|
|
41
|
+
# :attr: impress
|
|
42
|
+
#
|
|
43
|
+
# The image to display when pressed, based on an image or image name.
|
|
44
|
+
# This can use an actual image object, or the name of an image
|
|
45
|
+
# from +IupImageLib+.
|
|
46
|
+
|
|
47
|
+
# --
|
|
48
|
+
def impress
|
|
49
|
+
attribute_reference('IMPRESS', ImageWidget, nil)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def impress= val # :nodoc:
|
|
53
|
+
attribute_reference('IMPRESS', ImageWidget, val)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
|