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,150 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# A menu item is the interactive part of a menu, and acts like a button.
|
|
4
|
+
# The menu item can display a simple text label, an image,
|
|
5
|
+
# or act as a check box. When placed within a menu with the +radio+
|
|
6
|
+
# flag set, several menu items can act as a radio button group within
|
|
7
|
+
# a menu.
|
|
8
|
+
#
|
|
9
|
+
# === Example
|
|
10
|
+
#
|
|
11
|
+
# (1) Item with text and action.
|
|
12
|
+
#
|
|
13
|
+
# item_exit = Iup::MenuItem.new('Exit', ->{ Iup::CLOSE })
|
|
14
|
+
#
|
|
15
|
+
# (2) Checkbox
|
|
16
|
+
#
|
|
17
|
+
# show_toolbar = Iup::MenuItem.new('Show toolbar') do |i|
|
|
18
|
+
# i.value = :off # assign a value to make menu item a checkbox
|
|
19
|
+
# i.autotoggle = :yes # allow value to change when menu item clicked
|
|
20
|
+
# end
|
|
21
|
+
#
|
|
22
|
+
# Placing a set of checkbox menuitems into a Menu with +radio+ set
|
|
23
|
+
# turns the menuitems into a linked radio group.
|
|
24
|
+
#
|
|
25
|
+
# See also: Menu, Separator, SubMenu.
|
|
26
|
+
#
|
|
27
|
+
class MenuItem < Iup::Widget
|
|
28
|
+
|
|
29
|
+
# Creates a new instance.
|
|
30
|
+
# If a block is given, the new instance is yielded to it.
|
|
31
|
+
#
|
|
32
|
+
# * +title+ - text to display
|
|
33
|
+
# * +callback+ - Optional action to call when clicked with left button.
|
|
34
|
+
def initialize(title, callback = nil)
|
|
35
|
+
@handle = IupLib.IupItem(title, nil)
|
|
36
|
+
|
|
37
|
+
self.action = callback unless callback.nil?
|
|
38
|
+
|
|
39
|
+
# run any provided block on instance, to set up further attributes
|
|
40
|
+
yield self if block_given?
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# -- attributes
|
|
44
|
+
|
|
45
|
+
##
|
|
46
|
+
# :attr: autotoggle
|
|
47
|
+
# Sets auto toggle for item when menu activated, values 'yes' / 'no'.
|
|
48
|
+
# i.e. the menu item's check status is inverted when clicked.
|
|
49
|
+
define_attribute :autotoggle
|
|
50
|
+
|
|
51
|
+
##
|
|
52
|
+
# :attr: hidemark
|
|
53
|
+
# If set, hides the mark. Values 'yes' / 'no'.
|
|
54
|
+
define_attribute :hidemark
|
|
55
|
+
|
|
56
|
+
##
|
|
57
|
+
# :attr: image
|
|
58
|
+
# Image name or instance to show on menu when check enabled.
|
|
59
|
+
# This can use an actual image object, or the name of an image
|
|
60
|
+
# from +IupImageLib+.
|
|
61
|
+
|
|
62
|
+
# --
|
|
63
|
+
def image
|
|
64
|
+
attribute_reference('IMAGE', ImageWidget, nil)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def image= val # :nodoc:
|
|
68
|
+
attribute_reference('IMAGE', ImageWidget, val)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
##
|
|
72
|
+
# :attr: iminactive
|
|
73
|
+
# Image name or instance to show on menu when check disabled.
|
|
74
|
+
# This can use an actual image object, or the name of an image
|
|
75
|
+
# from +IupImageLib+.
|
|
76
|
+
|
|
77
|
+
# --
|
|
78
|
+
def iminactive
|
|
79
|
+
attribute_reference('IMINACTION', ImageWidget, nil)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def iminactive= val # :nodoc:
|
|
83
|
+
attribute_reference('IMINACTION', ImageWidget, val)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
##
|
|
87
|
+
# :attr: title
|
|
88
|
+
# Title text to display on menu item.
|
|
89
|
+
define_attribute :title
|
|
90
|
+
|
|
91
|
+
##
|
|
92
|
+
# :attr: titleimage
|
|
93
|
+
# Image name or instance to show on menu item.
|
|
94
|
+
# This can use an actual image object, or the name of an image
|
|
95
|
+
# from +IupImageLib+.
|
|
96
|
+
|
|
97
|
+
# --
|
|
98
|
+
def titleimage
|
|
99
|
+
attribute_reference('TITLEIMAGE', ImageWidget, nil)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def titleimage= val # :nodoc:
|
|
103
|
+
attribute_reference('TITLEIMAGE', ImageWidget, val)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
##
|
|
107
|
+
# :attr: value
|
|
108
|
+
# Determines if check is enabled or not, values 'off' / 'on'.
|
|
109
|
+
define_attribute :value
|
|
110
|
+
|
|
111
|
+
##
|
|
112
|
+
# :attr_reader: wid
|
|
113
|
+
# Native widget identifier.
|
|
114
|
+
define_attribute :wid
|
|
115
|
+
|
|
116
|
+
# :section: Callbacks
|
|
117
|
+
|
|
118
|
+
##
|
|
119
|
+
# :attr_writer: action
|
|
120
|
+
# Callback called when the element is activated.
|
|
121
|
+
# Callback must respond to +call+ and take no arguments.
|
|
122
|
+
|
|
123
|
+
# --
|
|
124
|
+
def action= callback
|
|
125
|
+
unless callback.arity.zero?
|
|
126
|
+
raise ArgumentError, 'action callback must take 0 arguments'
|
|
127
|
+
end
|
|
128
|
+
cb = Proc.new do |ih|
|
|
129
|
+
callback.call
|
|
130
|
+
end
|
|
131
|
+
define_callback cb, 'ACTION', :plain
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
##
|
|
135
|
+
# :attr_writer: highlight_cb
|
|
136
|
+
# Callback called when the item is highlighted.
|
|
137
|
+
# Callback must respond to +call+ and take no arguments.
|
|
138
|
+
|
|
139
|
+
# --
|
|
140
|
+
def highlight_cb= callback
|
|
141
|
+
unless callback.arity.zero?
|
|
142
|
+
raise ArgumentError, 'highlight_cb callback must take 0 arguments'
|
|
143
|
+
end
|
|
144
|
+
cb = Proc.new do |ih|
|
|
145
|
+
callback.call
|
|
146
|
+
end
|
|
147
|
+
define_callback cb, 'HIGHLIGHT_CB', :plain
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# Creates and shows an AlarmDialog, returning the number of the button clicked.
|
|
4
|
+
#
|
|
5
|
+
# * +title+ - the title of the dialog window
|
|
6
|
+
# * +msg+ - the text to display within the dialog
|
|
7
|
+
# * +button1+ - label for the first button
|
|
8
|
+
# * +button2+ - label for the optional second button
|
|
9
|
+
# * +button3+ - label for the optional third button
|
|
10
|
+
#
|
|
11
|
+
# Returns index of clicked button (1, 2 or 3).
|
|
12
|
+
#
|
|
13
|
+
# result = Iup.alarm("Vegetable time", "Pick a vegetable", "cabbage", "carrots", "peas")
|
|
14
|
+
#
|
|
15
|
+
# Also see: MessageDialog
|
|
16
|
+
#
|
|
17
|
+
def self.alarm title, msg, button1, button2=nil, button3=nil
|
|
18
|
+
IupLib.IupAlarm(title, msg, button1, button2, button3)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Convenience function to show a MessageDialog with given title and displayed
|
|
22
|
+
# message value. This is an "information" dialog, with a single button
|
|
23
|
+
# labelled "ok".
|
|
24
|
+
#
|
|
25
|
+
# Iup.message("About", <<MSG)
|
|
26
|
+
# My Ruby Application
|
|
27
|
+
#
|
|
28
|
+
# Date: January 2026
|
|
29
|
+
# MSG
|
|
30
|
+
#
|
|
31
|
+
# Also see: MessageDialog
|
|
32
|
+
#
|
|
33
|
+
def self.message(title, value)
|
|
34
|
+
IupLib.IupMessage(title, value)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# A predefined modal dialog used to display a message and requesting
|
|
38
|
+
# one of a constrained choice of responses.
|
|
39
|
+
#
|
|
40
|
+
# === Example
|
|
41
|
+
#
|
|
42
|
+
# The following example shows off many of the features, setting up a
|
|
43
|
+
# question-type dialog with three buttons and a default response of "no":
|
|
44
|
+
#
|
|
45
|
+
# md = Iup::MessageDialog.new do |d|
|
|
46
|
+
# d.title = "Example MessageDialog"
|
|
47
|
+
# d.dialogtype = 'question'
|
|
48
|
+
# d.value = "Should we do this?"
|
|
49
|
+
# d.buttons = 'yesnocancel'
|
|
50
|
+
# d.buttondefault = 2
|
|
51
|
+
# end
|
|
52
|
+
# md.popup
|
|
53
|
+
# puts "Clicked button is: #{md.buttonresponse}"
|
|
54
|
+
#
|
|
55
|
+
# Note that +popup+ must be used to show the dialog.
|
|
56
|
+
#
|
|
57
|
+
# Also see: Iup.message
|
|
58
|
+
#
|
|
59
|
+
class MessageDialog < Iup::Widget
|
|
60
|
+
|
|
61
|
+
# Creates a new dialog.
|
|
62
|
+
# If a block is given, the new instance is yielded to it.
|
|
63
|
+
def initialize
|
|
64
|
+
@handle = IupLib.IupMessageDlg
|
|
65
|
+
|
|
66
|
+
yield self if block_given?
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Shows the dialog at position x, y.
|
|
70
|
+
# * +x+ - x-coordinate to use, or one of {show constants}[../Iup.html#Dialog+show+position]
|
|
71
|
+
# * +y+ - y-coordinate to use, or one of {show constants}[../Iup.html#Dialog+show+position]
|
|
72
|
+
def popup x=0, y=0
|
|
73
|
+
IupLib.IupPopup @handle, x, y
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# -- attributes
|
|
77
|
+
|
|
78
|
+
##
|
|
79
|
+
# :attr: buttondefault
|
|
80
|
+
# Index of default button, '1' / '2' / '3'.
|
|
81
|
+
define_attribute :buttondefault
|
|
82
|
+
|
|
83
|
+
##
|
|
84
|
+
# :attr: buttonresponse
|
|
85
|
+
# Index of the pressed button, '1' / '2' / '3'.
|
|
86
|
+
define_attribute :buttonresponse
|
|
87
|
+
|
|
88
|
+
##
|
|
89
|
+
# :attr: buttons
|
|
90
|
+
# Choice of buttons to display: 'OK' / 'OKCANCEL' / 'RETRYCANCEL' / 'YESNO' / 'YESNOCANCEL'.
|
|
91
|
+
# If help_cb is defined, then a 'help' button is also displayed.
|
|
92
|
+
define_attribute :buttons
|
|
93
|
+
|
|
94
|
+
##
|
|
95
|
+
# :attr: dialogtype
|
|
96
|
+
# Selects the icon to display:
|
|
97
|
+
# 'error' / 'information' / 'message' / 'question' / 'warning'.
|
|
98
|
+
define_attribute :dialogtype
|
|
99
|
+
|
|
100
|
+
##
|
|
101
|
+
# :attr: parentdialog
|
|
102
|
+
# This dialog will be always in front of the parent dialog.
|
|
103
|
+
# If the parent is minimized, this dialog is automatically minimized.
|
|
104
|
+
# *Important* Closing the parent will also close the child, but the
|
|
105
|
+
# child dialog's CLOSE_CB method will not be called.
|
|
106
|
+
|
|
107
|
+
# --
|
|
108
|
+
def parentdialog
|
|
109
|
+
attribute_reference('PARENTDIALOG', Dialog, nil)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def parentdialog parent # :nodoc:
|
|
113
|
+
attribute_reference('PARENTDIALOG', Dialog, parent)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
##
|
|
117
|
+
# :attr: title
|
|
118
|
+
# Title text for the message dialog.
|
|
119
|
+
define_attribute :title
|
|
120
|
+
|
|
121
|
+
##
|
|
122
|
+
# :attr: value
|
|
123
|
+
# Message text to display within the dialog.
|
|
124
|
+
define_attribute :value
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# A progress bar control, showing a percent-complete value.
|
|
4
|
+
# Typically used to show the progress of a long-running task
|
|
5
|
+
# running within a Timer.
|
|
6
|
+
#
|
|
7
|
+
# === Example
|
|
8
|
+
#
|
|
9
|
+
# The following creates a vertical bar, starting at a value of 25 out of 50.
|
|
10
|
+
#
|
|
11
|
+
# Iup::ProgressBar.new do |p|
|
|
12
|
+
# p.orientation = 'vertical'
|
|
13
|
+
# p.bgcolor = '255 0 128'
|
|
14
|
+
# p.fgcolor = '0 128 0'
|
|
15
|
+
# p.rastersize = '30x100'
|
|
16
|
+
# p.max = 50
|
|
17
|
+
# p.value = 25
|
|
18
|
+
# end
|
|
19
|
+
#
|
|
20
|
+
# Also see: ProgressDialog, Timer.
|
|
21
|
+
#
|
|
22
|
+
class ProgressBar < Iup::Widget
|
|
23
|
+
|
|
24
|
+
# Creates an instance of a progress bar.
|
|
25
|
+
# If a block is given, the new instance is yielded to it.
|
|
26
|
+
def initialize
|
|
27
|
+
@handle = IupLib.IupProgressBar
|
|
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: dashed
|
|
37
|
+
# Changes style of progress bar to a dashed pattern, as 'yes' / 'no'.
|
|
38
|
+
define_attribute :dashed
|
|
39
|
+
|
|
40
|
+
##
|
|
41
|
+
# :attr: expand
|
|
42
|
+
# Allows bar to fill available space in indicated direction.
|
|
43
|
+
# Values 'no' / 'horizontal' / 'vertical' / 'yes'.
|
|
44
|
+
define_attribute :expand
|
|
45
|
+
|
|
46
|
+
##
|
|
47
|
+
# :attr: marquee
|
|
48
|
+
# Displays an undefined state if set. Values 'yes' / 'no'.
|
|
49
|
+
define_attribute :marquee
|
|
50
|
+
|
|
51
|
+
##
|
|
52
|
+
# :attr: max
|
|
53
|
+
# maximum value, default 1.
|
|
54
|
+
define_attribute :max
|
|
55
|
+
|
|
56
|
+
##
|
|
57
|
+
# :attr: min
|
|
58
|
+
# minimum value, default 0.
|
|
59
|
+
define_attribute :min
|
|
60
|
+
|
|
61
|
+
##
|
|
62
|
+
# :attr: orientation
|
|
63
|
+
# 'horizontal' / 'vertical'.
|
|
64
|
+
define_attribute :orientation
|
|
65
|
+
|
|
66
|
+
##
|
|
67
|
+
# :attr_reader: position
|
|
68
|
+
# returns position in pixels within client window as "x,y".
|
|
69
|
+
define_reader :position
|
|
70
|
+
|
|
71
|
+
##
|
|
72
|
+
# :attr: rastersize
|
|
73
|
+
# Size of the widget, in pixels, value as "widthxheight".
|
|
74
|
+
define_attribute :rastersize
|
|
75
|
+
|
|
76
|
+
##
|
|
77
|
+
# :attr_reader: screenposition
|
|
78
|
+
# returns position in pixels on screen as "x,y".
|
|
79
|
+
define_reader :screenposition
|
|
80
|
+
|
|
81
|
+
##
|
|
82
|
+
# :attr: tip
|
|
83
|
+
# Tooltip string.
|
|
84
|
+
define_attribute :tip
|
|
85
|
+
|
|
86
|
+
##
|
|
87
|
+
# :attr: value
|
|
88
|
+
# number between +min+ and +max+, for current position.
|
|
89
|
+
define_attribute :value
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# A predefined dialog to show the progress of an operation.
|
|
4
|
+
# It is often used alongside a Iup::Timer, which triggers
|
|
5
|
+
# updates at regular intervals.
|
|
6
|
+
#
|
|
7
|
+
# === Example
|
|
8
|
+
#
|
|
9
|
+
# dlg = Iup::ProgressDialog.new do |d|
|
|
10
|
+
# d.title = "Progress on task ..."
|
|
11
|
+
# d.description = "... taking a long time"
|
|
12
|
+
# d.totalcount = 100
|
|
13
|
+
# d.count = 30
|
|
14
|
+
# d.cancel_cb = ->{
|
|
15
|
+
# puts "Task cancelled"
|
|
16
|
+
# Iup::CLOSE
|
|
17
|
+
# }
|
|
18
|
+
# end
|
|
19
|
+
# dlg.show
|
|
20
|
+
#
|
|
21
|
+
# The dialog is meant to be shown using +show+.
|
|
22
|
+
#
|
|
23
|
+
class ProgressDialog < Iup::Dialog
|
|
24
|
+
|
|
25
|
+
# Creates an instance of the dialog.
|
|
26
|
+
# If a block is given, the new instance is yielded to it.
|
|
27
|
+
def initialize
|
|
28
|
+
@handle = IupLib.IupProgressDlg
|
|
29
|
+
|
|
30
|
+
# run any provided block on instance, to set up further attributes
|
|
31
|
+
yield self if block_given?
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# -- attributes
|
|
35
|
+
|
|
36
|
+
##
|
|
37
|
+
# :attr: count
|
|
38
|
+
# n, number of iterations completed so far.
|
|
39
|
+
define_attribute :count
|
|
40
|
+
|
|
41
|
+
##
|
|
42
|
+
# :attr: description
|
|
43
|
+
# The text to show within the dialog, describing operation.
|
|
44
|
+
define_attribute :description
|
|
45
|
+
|
|
46
|
+
##
|
|
47
|
+
# :attr_writer: inc
|
|
48
|
+
# n, increases progress by +n+.
|
|
49
|
+
define_writer :inc
|
|
50
|
+
|
|
51
|
+
##
|
|
52
|
+
# :attr: percent
|
|
53
|
+
# n, current percent of iterations.
|
|
54
|
+
define_attribute :percent
|
|
55
|
+
|
|
56
|
+
##
|
|
57
|
+
# :attr: state
|
|
58
|
+
# current state of the iteration, values 'idle' / 'processing' / 'undefined' / 'aborted'.
|
|
59
|
+
define_attribute :state
|
|
60
|
+
|
|
61
|
+
##
|
|
62
|
+
# :attr: totalcount
|
|
63
|
+
# n, total number of iterations to complete.
|
|
64
|
+
define_attribute :totalcount
|
|
65
|
+
|
|
66
|
+
# :section: Callbacks
|
|
67
|
+
|
|
68
|
+
##
|
|
69
|
+
# :attr_writer: cancel_cb
|
|
70
|
+
# Callback called when the user clicked on the Cancel button.
|
|
71
|
+
# Callback must respond to +call+ and take no arguments.
|
|
72
|
+
# Returns different to Iup::CONTINUE will set state to 'aborted'.
|
|
73
|
+
|
|
74
|
+
# --
|
|
75
|
+
def cancel_cb= callback
|
|
76
|
+
unless callback.arity.zero?
|
|
77
|
+
raise ArgumentError, 'cancel_cb callback must take 0 arguments'
|
|
78
|
+
end
|
|
79
|
+
cb = Proc.new do |ih|
|
|
80
|
+
callback.call
|
|
81
|
+
end
|
|
82
|
+
define_callback cb, 'CANCEL_CB', :plain
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# A Radio container is used to group toggle controls together, so that only one
|
|
4
|
+
# out of the group will be active at a time.
|
|
5
|
+
#
|
|
6
|
+
# To use the Radio control, place the toggle controls within a vbox/hbox and
|
|
7
|
+
# add to the radio control.
|
|
8
|
+
#
|
|
9
|
+
# === Example
|
|
10
|
+
#
|
|
11
|
+
# This example sets up two options: Perl and Ruby. Notice the use of
|
|
12
|
+
# +assign_handle+ in the toggles to provide a meaningful name to the radio
|
|
13
|
+
# group's current +value+:
|
|
14
|
+
#
|
|
15
|
+
# perl = Iup::Toggle.new('Perl') do |t|
|
|
16
|
+
# t.assign_handle 'perl'
|
|
17
|
+
# end
|
|
18
|
+
#
|
|
19
|
+
# ruby = Iup::Toggle.new('Ruby') do |t|
|
|
20
|
+
# t.assign_handle 'ruby'
|
|
21
|
+
# end
|
|
22
|
+
#
|
|
23
|
+
# exclusive = Iup::Radio.new(Iup::VBox.new(perl, ruby)) do |r|
|
|
24
|
+
# r.value = 'ruby'
|
|
25
|
+
# end
|
|
26
|
+
#
|
|
27
|
+
class Radio < Iup::Widget
|
|
28
|
+
include DynamicFillMethods
|
|
29
|
+
|
|
30
|
+
# Creates an instance of the radio container.
|
|
31
|
+
# If a block is given, the new instance is yielded to it.
|
|
32
|
+
# * +toggles+ - a vbox or hbox containing the toggle controls
|
|
33
|
+
def initialize toggles
|
|
34
|
+
@handle = IupLib.IupRadio(toggles.handle)
|
|
35
|
+
|
|
36
|
+
# run any provided block on instance, to set up further attributes
|
|
37
|
+
yield self if block_given?
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# -- attributes
|
|
41
|
+
|
|
42
|
+
##
|
|
43
|
+
# :attr_reader: clientoffset
|
|
44
|
+
# Returns current offset of frame in its client as "widthxheight".
|
|
45
|
+
define_reader :clientoffset
|
|
46
|
+
|
|
47
|
+
##
|
|
48
|
+
# :attr_reader: clientsize
|
|
49
|
+
# Returns current size of frame as "widthxheight".
|
|
50
|
+
define_reader :clientsize
|
|
51
|
+
|
|
52
|
+
##
|
|
53
|
+
# :attr: expand
|
|
54
|
+
# Allows container to fill available space in indicated direction.
|
|
55
|
+
# Values 'no' / 'horizontal' / 'vertical' / 'yes'.
|
|
56
|
+
define_attribute :expand
|
|
57
|
+
|
|
58
|
+
##
|
|
59
|
+
# :attr_reader: position
|
|
60
|
+
# Returns position in pixels within client window as "x,y".
|
|
61
|
+
define_reader :position
|
|
62
|
+
|
|
63
|
+
##
|
|
64
|
+
# :attr: value
|
|
65
|
+
# Name identifier of the active toggle.
|
|
66
|
+
define_attribute :value
|
|
67
|
+
|
|
68
|
+
##
|
|
69
|
+
# :attr: value_handle
|
|
70
|
+
# Changes the active toggle to given name.
|
|
71
|
+
define_attribute :value_handle
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|