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/dial.rb
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
class Dial < Widget
|
|
4
|
+
|
|
5
|
+
def initialize orientation = 'horizontal', &block
|
|
6
|
+
open_controls
|
|
7
|
+
@handle = ControlsLib.IupDial orientation
|
|
8
|
+
|
|
9
|
+
# run any provided block on instance, to set up further attributes
|
|
10
|
+
self.instance_eval &block if block_given?
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# -- attributes
|
|
14
|
+
|
|
15
|
+
define_attribute :expand
|
|
16
|
+
define_attribute :orientation
|
|
17
|
+
define_readonly :position
|
|
18
|
+
define_attribute :rastersize
|
|
19
|
+
define_readonly :screenposition
|
|
20
|
+
define_attribute :tip
|
|
21
|
+
define_attribute :unit
|
|
22
|
+
|
|
23
|
+
def value val=nil
|
|
24
|
+
if val.nil?
|
|
25
|
+
result = IupLib.IupGetAttribute(@handle, 'VALUE').first
|
|
26
|
+
result.to_f
|
|
27
|
+
else
|
|
28
|
+
IupLib.IupSetAttribute @handle, 'VALUE', val.to_s
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# -- callbacks
|
|
33
|
+
|
|
34
|
+
include ButtonCallback
|
|
35
|
+
|
|
36
|
+
# Called when the user presses the left mouse button over the dial.
|
|
37
|
+
# The angle here is always zero, except for the circular dial.
|
|
38
|
+
# Callback is a 1-argument function: (angle)
|
|
39
|
+
def button_press_cb callback
|
|
40
|
+
unless callback.arity == 1
|
|
41
|
+
raise ArgumentError, 'button_press_cb callback must take 1 argument: (angle)'
|
|
42
|
+
end
|
|
43
|
+
cb = Proc.new do |ih, angle|
|
|
44
|
+
callback.call angle
|
|
45
|
+
end
|
|
46
|
+
define_callback cb, 'BUTTON_PRESS_CB', :d_i
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Called when the user releases the left mouse button after pressing it over the dial.
|
|
50
|
+
# The angle here is always zero, except for the circular dial.
|
|
51
|
+
# Callback is a 1-argument function: (angle)
|
|
52
|
+
def button_release_cb callback
|
|
53
|
+
unless callback.arity == 1
|
|
54
|
+
raise ArgumentError, 'button_release_cb callback must take 1 argument: (angle)'
|
|
55
|
+
end
|
|
56
|
+
cb = Proc.new do |ih, angle|
|
|
57
|
+
callback.call angle
|
|
58
|
+
end
|
|
59
|
+
define_callback cb, 'BUTTON_RELEASE_CB', :d_i
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Called each time the user moves the dial with the mouse button pressed.
|
|
63
|
+
# The angle the dial rotated since it was initialized is passed as a parameter.
|
|
64
|
+
# Callback is a 1-argument function: (angle)
|
|
65
|
+
def mousemove_cb callback
|
|
66
|
+
unless callback.arity == 1
|
|
67
|
+
raise ArgumentError, 'mousemove_cb callback must take 1 argument: (angle)'
|
|
68
|
+
end
|
|
69
|
+
cb = Proc.new do |ih, angle|
|
|
70
|
+
callback.call angle
|
|
71
|
+
end
|
|
72
|
+
define_callback cb, 'MOUSEMOVE_CB', :d_i
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Called after the value was interactively changed by the user. Called when
|
|
76
|
+
# the selection is changed or when the text is edited.
|
|
77
|
+
def valuechanged_cb callback
|
|
78
|
+
unless callback.arity.zero?
|
|
79
|
+
raise ArgumentError, 'valuechanged_cb callback must take 0 arguments'
|
|
80
|
+
end
|
|
81
|
+
cb = Proc.new do |ih|
|
|
82
|
+
callback.call
|
|
83
|
+
end
|
|
84
|
+
define_callback cb, 'VALUECHANGED_CB', :plain
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# A Dialog is a top-level window, containing a single widget.
|
|
4
|
+
#
|
|
5
|
+
# == Attributes
|
|
6
|
+
#
|
|
7
|
+
# background:: RGB colour for background of dialog and children.
|
|
8
|
+
# border:: If set, displays a resize border around dialog.
|
|
9
|
+
# clientsize:: <b>read-only</b>, returns current size of box as "widthxheight".
|
|
10
|
+
# cursor:: Defines the mouse shape / cursor for the dialog.
|
|
11
|
+
# expand:: Allows container to fill available space in indicated direction.
|
|
12
|
+
# Values 'no' / 'horizontal' / 'vertical' / 'yes'.
|
|
13
|
+
# fullscreen:: 'no' / 'yes'.
|
|
14
|
+
# maxbox:: 'no' / 'yes', to show maximize box on dialog.
|
|
15
|
+
# menubox:: 'no' / 'yes', to show system menu box on dialog.
|
|
16
|
+
# minbox:: 'no' / 'yes', to show minimize box on dialog.
|
|
17
|
+
# modal:: <b>read-only</b> Returns modal state of dialog.
|
|
18
|
+
# parentdialog:: Sets/retrieves dialog to use as parent of this dialog.
|
|
19
|
+
# placement:: 'normal' / 'maximized' / 'minimized' / 'full'.
|
|
20
|
+
# rastersize:: Size of the dialog, in pixels, value as "widthxheight".
|
|
21
|
+
# resize:: 'no' / 'yes'.
|
|
22
|
+
# shrink:: 'no' / 'yes', allows dialog's children to reduce their size if
|
|
23
|
+
# the dialog is made smaller.
|
|
24
|
+
# screenposition:: <b>read-only</b> returns position in pixels on screen
|
|
25
|
+
# as "x,y".
|
|
26
|
+
# size:: Size of the dialog, in character units, value as "widthxheight".
|
|
27
|
+
# Can also use: 'full' / 'half' / 'third' / 'quarter' / 'eighth'.
|
|
28
|
+
# startfocus:: Name of widget to gain focus when dialog first shown.
|
|
29
|
+
# tip:: Tooltip string.
|
|
30
|
+
# title:: text displayed as dialog title.
|
|
31
|
+
#
|
|
32
|
+
class Dialog < Widget
|
|
33
|
+
include DragDropAttributes
|
|
34
|
+
|
|
35
|
+
include AttributeReference
|
|
36
|
+
|
|
37
|
+
# Creates a new dialog for given widget.
|
|
38
|
+
# widget:: the child widget to display.
|
|
39
|
+
# block:: optional block to set up attributes.
|
|
40
|
+
def initialize widget, &block
|
|
41
|
+
@handle = IupLib.IupDialog widget.handle
|
|
42
|
+
|
|
43
|
+
# run any provided block on instance, to set up further attributes
|
|
44
|
+
self.instance_eval &block if block_given?
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Hides the dialog from view.
|
|
48
|
+
def hide
|
|
49
|
+
IupLib.IupHide @handle
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Lays out the child widget and its contents, without showign the dialog.
|
|
53
|
+
def map
|
|
54
|
+
IupLib.IupMap @handle
|
|
55
|
+
self
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Shows the dialog at position (x, y).
|
|
59
|
+
def popup x, y
|
|
60
|
+
IupLib.IupPopup @handle, x.to_i, y.to_i
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Shows the dialog at the default screen position,
|
|
64
|
+
# or at (x, y) if specified.
|
|
65
|
+
def show x=nil, y=nil
|
|
66
|
+
if x.nil? and y.nil?
|
|
67
|
+
IupLib.IupShow @handle
|
|
68
|
+
else
|
|
69
|
+
IupLib.IupShowXY @handle, x.to_i, y.to_i
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# -- attributes
|
|
74
|
+
|
|
75
|
+
# --- common
|
|
76
|
+
|
|
77
|
+
define_attribute :background
|
|
78
|
+
define_attribute :border
|
|
79
|
+
define_readonly :clientsize
|
|
80
|
+
|
|
81
|
+
def cursor image=nil # :nodoc:
|
|
82
|
+
attribute_reference 'CURSOR', ImageWidget, image
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
define_attribute :expand
|
|
86
|
+
define_attribute :rastersize
|
|
87
|
+
define_readonly :screenposition
|
|
88
|
+
define_attribute :tip
|
|
89
|
+
define_attribute :title
|
|
90
|
+
|
|
91
|
+
# --- exclusive
|
|
92
|
+
|
|
93
|
+
# Identifies button to activate when 'enter' is pressed.
|
|
94
|
+
# Leave item nil to retrieve current button.
|
|
95
|
+
def defaultenter item=nil
|
|
96
|
+
attribute_reference 'DEFAULTENTER', Button, item
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Identifies button to activate when 'escape' is pressed.
|
|
100
|
+
# Leave item nil to retrieve current button.
|
|
101
|
+
def defaultesc item=nil
|
|
102
|
+
attribute_reference 'DEFAULTESC', Button, item
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
define_attribute :fullscreen
|
|
106
|
+
|
|
107
|
+
# Defines or retrieves icon to use for dialog.
|
|
108
|
+
# item:: optional instance of ImageWidget
|
|
109
|
+
def icon item=nil
|
|
110
|
+
attribute_reference 'ICON', ImageWidget, item
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
define_attribute :maxbox
|
|
114
|
+
|
|
115
|
+
# Assigns given item as the menu for this dialog.
|
|
116
|
+
# item may be an instance of Menu, or the string name for a menu.
|
|
117
|
+
def menu item=nil
|
|
118
|
+
attribute_reference 'MENU', Menu, item
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
define_attribute :menubox
|
|
122
|
+
define_attribute :minbox
|
|
123
|
+
define_readonly :modal
|
|
124
|
+
|
|
125
|
+
def parentdialog parent=nil # :nodoc:
|
|
126
|
+
attribute_reference 'PARENTDIALOG', Dialog, parent
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
define_attribute :placement
|
|
130
|
+
define_attribute :resize
|
|
131
|
+
define_attribute :shrink
|
|
132
|
+
|
|
133
|
+
def startfocus item=nil # :nodoc:
|
|
134
|
+
attribute_reference 'STARTFOCUS', Widget, item
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# -- callbacks
|
|
138
|
+
|
|
139
|
+
# Called right before the dialog is closed.
|
|
140
|
+
def close_cb callback
|
|
141
|
+
unless callback.arity.zero?
|
|
142
|
+
raise ArgumentError, 'close_cb callback must take 0 arguments'
|
|
143
|
+
end
|
|
144
|
+
cb = Proc.new do |ih|
|
|
145
|
+
callback.call
|
|
146
|
+
end
|
|
147
|
+
define_callback cb, 'CLOSE_CB', :plain
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# Action generated when the canvas size is changed.
|
|
151
|
+
# resize_cb a 2-argument callback: (width, height).
|
|
152
|
+
# width:: internal width of canvas (client width)
|
|
153
|
+
# height:: internal height of canvas (client height)
|
|
154
|
+
def resize_cb callback
|
|
155
|
+
unless callback.arity == 2
|
|
156
|
+
raise ArgumentError, 'resize_cb callback must take 2 arguments: (width, height)'
|
|
157
|
+
end
|
|
158
|
+
cb = Proc.new do |ih, width, height|
|
|
159
|
+
callback.call width, height
|
|
160
|
+
end
|
|
161
|
+
define_callback cb, 'RESIZE_CB', :ii_i
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Called right after the dialog is shown, hidden, maximized, minimized or restored from minimized/maximized.
|
|
165
|
+
# Callback takes one argument, the state of the change.
|
|
166
|
+
def show_cb callback
|
|
167
|
+
unless callback.arity == 1
|
|
168
|
+
raise ArgumentError, 'show_cb callback must take 1 argument: (state)'
|
|
169
|
+
end
|
|
170
|
+
cb = Proc.new do |ih, state|
|
|
171
|
+
callback.call state
|
|
172
|
+
end
|
|
173
|
+
define_callback cb, 'SHOW_CB', :i_i
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# Creates and shows an AlarmDialog, returning the number of the button clicked.
|
|
4
|
+
#
|
|
5
|
+
# mainloop do
|
|
6
|
+
# case alarm 'IupAlarm Example', 'File not saved! Save it now?', 'Yes', 'No', 'Cancel'
|
|
7
|
+
# when 1
|
|
8
|
+
# message 'Save file', 'File saved successfully - leaving program'
|
|
9
|
+
# when 2
|
|
10
|
+
# message 'Save file', 'File not saved - leaving program anyway'
|
|
11
|
+
# when 3
|
|
12
|
+
# message 'Save file', 'Operation cancelled'
|
|
13
|
+
# end
|
|
14
|
+
# exit # needed, as we don't have a persistent dialog, so don't wish to run the mainloop
|
|
15
|
+
# end
|
|
16
|
+
#
|
|
17
|
+
# title:: the title of the dialog window
|
|
18
|
+
# msg:: the text to display within the dialog
|
|
19
|
+
# button1:: label for the first button
|
|
20
|
+
# button2:: label for the optional second button
|
|
21
|
+
# button3:: label for the optional third button
|
|
22
|
+
#
|
|
23
|
+
def alarm title, msg, button1, button2=nil, button3=nil
|
|
24
|
+
IupLib.IupAlarm title, msg, button1, button2, button3
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Shows a modal dialog allowing user to select a colour.
|
|
28
|
+
# As input, provide the x,y coordinates to show dialog.
|
|
29
|
+
# Returns r/g/b triple of selected colour, or nil if "cancel" clicked.
|
|
30
|
+
#
|
|
31
|
+
# r, g, b = get_colour 150, 150
|
|
32
|
+
#
|
|
33
|
+
def get_colour x=0, y=0
|
|
34
|
+
r = FFI::MemoryPointer.new(:int, 1, 0)
|
|
35
|
+
g = FFI::MemoryPointer.new(:int, 1, 0)
|
|
36
|
+
b = FFI::MemoryPointer.new(:int, 1, 0)
|
|
37
|
+
code = IupLib.IupGetColor x, y, r, g, b
|
|
38
|
+
if code == 0
|
|
39
|
+
return nil, nil, nil
|
|
40
|
+
else
|
|
41
|
+
return r.read_int, g.read_int, b.read_int
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Convenience function to show a modal dialog to select a filename.
|
|
46
|
+
# As input, accepts a path and filter for the file.
|
|
47
|
+
# Returns the status code and selected filename.
|
|
48
|
+
#
|
|
49
|
+
# Example, selecting a filename ending in ".txt" from current directory.
|
|
50
|
+
#
|
|
51
|
+
# code, file = get_file './*.txt'
|
|
52
|
+
#
|
|
53
|
+
def get_file filter=''
|
|
54
|
+
file = ' '*(256-filter.size) + filter
|
|
55
|
+
code = IupLib.IupGetFile file
|
|
56
|
+
case code
|
|
57
|
+
when 0, 1
|
|
58
|
+
filename = file[0...file.index("\0")]
|
|
59
|
+
return code, filename
|
|
60
|
+
else
|
|
61
|
+
return code, ''
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Show a modal dialog to edit a multiline text.
|
|
66
|
+
# Returns the text or nil if cancelled.
|
|
67
|
+
# Assumes 2048 as maximum length, unless a larger text is input.
|
|
68
|
+
#
|
|
69
|
+
# text:: Initial text to display.
|
|
70
|
+
# title:: Title of dialog box.
|
|
71
|
+
#--
|
|
72
|
+
# TODO: Crashes - double free or corruption.
|
|
73
|
+
# def get_text title, text=''
|
|
74
|
+
# text += ' '*(2048-text.size)
|
|
75
|
+
# text_ptr = FFI::MemoryPointer.from_string text
|
|
76
|
+
# code = IupLib.IupGetText FFI::MemoryPointer.from_string(title), text_ptr
|
|
77
|
+
# return (code.zero? ? nil : text_ptr.read_string.force_encoding('UTF-8').strip)
|
|
78
|
+
# end
|
|
79
|
+
|
|
80
|
+
# show a list dialog.
|
|
81
|
+
# returns selected item, or nil if cancel clicked.
|
|
82
|
+
#--
|
|
83
|
+
# TODO: Include multiple selection, change to cols/lines
|
|
84
|
+
def listdialog title, items
|
|
85
|
+
strptrs = []
|
|
86
|
+
strptrs << nil
|
|
87
|
+
|
|
88
|
+
items_ptr = FFI::MemoryPointer.new(:pointer, items.length)
|
|
89
|
+
items.each_with_index do |item, i|
|
|
90
|
+
items_ptr[i].put_pointer(0, FFI::MemoryPointer.from_string(item))
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
code = IupLib.IupListDialog 1, title, items.length, items_ptr, 1, 1, 10, nil
|
|
94
|
+
|
|
95
|
+
return (code == -1 ? nil : items[code])
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Create a MessageDialog with given title and displayed message.
|
|
99
|
+
#
|
|
100
|
+
# message "title of dialog", "text of message"
|
|
101
|
+
#
|
|
102
|
+
def message title, msg
|
|
103
|
+
IupLib.IupMessage title, msg
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# defines attributes and methods for drag and drop
|
|
4
|
+
#
|
|
5
|
+
# Steps to use the Drag & Drop support in an IUP application:
|
|
6
|
+
#
|
|
7
|
+
# AT SOURCE::
|
|
8
|
+
# * Enable the element as source using the attribute DRAGSOURCE=YES;
|
|
9
|
+
# * Define the data types supported by the element for the drag operation using the DRAGTYPES attribute;
|
|
10
|
+
# * Register the required callbacks DRAGBEGIN_CB, DRAGDATASIZE_CB and DRAGDATA_CB for drag handling. DRAGEND_CB is the only optional drag callback, all other callbacks and attributes must be set.
|
|
11
|
+
# AT TARGET::
|
|
12
|
+
# * Enable the element as target using the attribute DROPTARGET=YES;
|
|
13
|
+
# * Define the data types supported by the element for the drop using the DROPTYPES attribute;
|
|
14
|
+
# * Register the required callback DROPDATA_CB for handling the data received. This callback and all the drop target attributes must be set too. DROPMOTION_CB is the only optional drop callback.
|
|
15
|
+
#
|
|
16
|
+
module DragDropAttributes
|
|
17
|
+
extend AttributeBuilders
|
|
18
|
+
|
|
19
|
+
# attributes for drag-n-drop
|
|
20
|
+
|
|
21
|
+
define_attribute :dragsource
|
|
22
|
+
define_attribute :dragtypes
|
|
23
|
+
define_attribute :dragsourcemove
|
|
24
|
+
define_attribute :droptarget
|
|
25
|
+
define_attribute :droptypes
|
|
26
|
+
|
|
27
|
+
# callbacks for drag-n-drop
|
|
28
|
+
|
|
29
|
+
def dragbegin_cb callback
|
|
30
|
+
define_callback callback, 'DRAGBEGIN_CB', :ii_i
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def dragdatasize_cb callback
|
|
34
|
+
define_callback callback, 'DRAGDATASIZE_CB', :s_i
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Note: user data assumed to be a string
|
|
38
|
+
def dragdata_cb callback
|
|
39
|
+
define_callback callback, 'DRAGDATA_CB', :ssi_i
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def dragend_cb callback
|
|
43
|
+
define_callback callback, 'DRAGEND_CB', :i_i
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Note: user data assumed to be a string
|
|
47
|
+
def dropdata_cb callback
|
|
48
|
+
define_callback callback, 'DROPDATA_CB', :ssiii_i
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def dropmotion_cb callback
|
|
52
|
+
define_callback callback, 'DROPMOTION_CB', :iis_i
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# Methods for containers where the child elements can be added after construction.
|
|
4
|
+
#
|
|
5
|
+
module DynamicFillMethods
|
|
6
|
+
|
|
7
|
+
# Inserts an interface element at the end of the container,
|
|
8
|
+
# after the last element of the container.
|
|
9
|
+
# Valid for any element that contains other elements like
|
|
10
|
+
# dialog, frame, hbox, vbox, zbox or menu.
|
|
11
|
+
def append child
|
|
12
|
+
IupLib.IupAppend @handle, child.handle
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Inserts an interface element before another child of the container.
|
|
16
|
+
# Valid for any element that contains other elements like
|
|
17
|
+
# dialog, frame, hbox, vbox, zbox, menu, etc.
|
|
18
|
+
def insert ref_child, new_child
|
|
19
|
+
if ref_child.nil?
|
|
20
|
+
IupLib.IupInsert @handle, nil, new_child.handle
|
|
21
|
+
else
|
|
22
|
+
IupLib.IupInsert @handle, ref_child.handle, new_child.handle
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# An expandable container for a single widget.
|
|
4
|
+
# The user can show or hide the child widget, as required.
|
|
5
|
+
#
|
|
6
|
+
# == Attributes
|
|
7
|
+
#
|
|
8
|
+
# autoshow:: If set, child will be shown when mouse hovers over container.
|
|
9
|
+
# Values 'yes' / 'no'.
|
|
10
|
+
# backcolor:: Colour of background in title area, as "r g b".
|
|
11
|
+
# barposition:: Position of expander bar, as 'top' / 'bottom' / 'left' / 'right'.
|
|
12
|
+
# barsize:: n, size of bar - defaults to text line height + 5.
|
|
13
|
+
# clientoffset:: <b>read-only</b>, returns current offset of box in its client
|
|
14
|
+
# as "widthxheight".
|
|
15
|
+
# clientsize:: <b>read-only</b>, returns current size of box as "widthxheight".
|
|
16
|
+
# expand:: Allows container to fill available space in indicated direction.
|
|
17
|
+
# Values 'no' / 'horizontal' / 'vertical' / 'yes'.
|
|
18
|
+
# forecolor:: Colour of text in title area, as "r g b".
|
|
19
|
+
# position:: <b>read-only</b> returns position in pixels within client window
|
|
20
|
+
# as "x,y".
|
|
21
|
+
# rastersize:: Size of the container, in pixels, value as "widthxheight".
|
|
22
|
+
# state:: Show or hide child, as 'open' / 'close'.
|
|
23
|
+
# title:: Displayed on box in title area.
|
|
24
|
+
#
|
|
25
|
+
class Expander < Widget
|
|
26
|
+
|
|
27
|
+
# Creates an instance of the Expander.
|
|
28
|
+
# child:: the child widget
|
|
29
|
+
# block:: optional block to set up the container's attributes.
|
|
30
|
+
def initialize child, &block
|
|
31
|
+
@handle = IupLib.IupExpander child.handle
|
|
32
|
+
|
|
33
|
+
self.instance_eval &block if block_given?
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# -- attributes
|
|
37
|
+
|
|
38
|
+
define_attribute :autoshow
|
|
39
|
+
define_attribute :backcolor
|
|
40
|
+
define_attribute :barposition
|
|
41
|
+
define_attribute :barsize
|
|
42
|
+
define_readonly :clientoffset
|
|
43
|
+
define_readonly :clientsize
|
|
44
|
+
define_attribute :expand
|
|
45
|
+
define_attribute :forecolor
|
|
46
|
+
define_attribute :position
|
|
47
|
+
define_attribute :rastersize
|
|
48
|
+
define_attribute :state
|
|
49
|
+
define_attribute :title
|
|
50
|
+
|
|
51
|
+
# -- callbacks
|
|
52
|
+
|
|
53
|
+
# Action generated after the expander state is interactively changed.
|
|
54
|
+
# callback:: a zero-argument procedure
|
|
55
|
+
def action_cb callback
|
|
56
|
+
unless callback.arity.zero?
|
|
57
|
+
raise ArgumentError, 'action_cb callback must take 0 arguments'
|
|
58
|
+
end
|
|
59
|
+
cb = Proc.new do |ih|
|
|
60
|
+
callback.call
|
|
61
|
+
end
|
|
62
|
+
define_callback cb, 'ACTION_CB', :plain
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# A FileDialog is a predefined dialog for selecting files or a directory.
|
|
4
|
+
# The dialog can only be shown using the popup function.
|
|
5
|
+
#
|
|
6
|
+
# == Attributes
|
|
7
|
+
#
|
|
8
|
+
# allownew:: If set, indicates if non-existent filenames are accepted.
|
|
9
|
+
# Values as 'yes' / 'no' - defaults to 'no'.
|
|
10
|
+
# dialogtype:: 'open' / 'save' / 'dir'
|
|
11
|
+
# directory:: Initial directory
|
|
12
|
+
# extfilter:: Defines filters, e.g. "Text files\|*.txt;*.doc\|Image files\|*.gif;*.jpg;*.bmp\|",
|
|
13
|
+
# has priority over +filterinfo+ and +filter+.
|
|
14
|
+
# file:: Name of file. Will be used instead of +dictionary+ if it contains
|
|
15
|
+
# a complete path.
|
|
16
|
+
# filter:: Filter to use, e.g. "*.C;*.LED;test.*".
|
|
17
|
+
# filterinfo:: Information about the +filter+, e.g. "C files".
|
|
18
|
+
# filterused:: n, index of filter from +extfilter+ that was used.
|
|
19
|
+
# Index counts from 1.
|
|
20
|
+
# multiplefiles:: 'no' / 'yes', set to allow selection of multiple files.
|
|
21
|
+
# nochangedir:: 'yes' / 'no', if set, restores current directory after dialog is closed.
|
|
22
|
+
# nooverwriteprompt:: 'no' / 'yes', if set, prompts before overwriting existing files.
|
|
23
|
+
# parentdialog:: This dialog will be always in front of the parent dialog.
|
|
24
|
+
# If the parent is minimized, this dialog is automatically minimized.
|
|
25
|
+
# *Important* Closing the parent will also close the child, but the
|
|
26
|
+
# child dialog's CLOSE_CB method will not be called.
|
|
27
|
+
# showhidden:: 'no' / 'yes', if set, shows hidden files.
|
|
28
|
+
# showpreview:: 'no' / 'yes', if set, shows a preview area for file.
|
|
29
|
+
# status:: <b>read-only</b> Returns an integer: 1 for new file, 0 for existing file/directory, for -1 for cancelled.
|
|
30
|
+
# title:: Title text for the file dialog.
|
|
31
|
+
# value:: <b>read-only</b> Name of file(s) selected.
|
|
32
|
+
#
|
|
33
|
+
class FileDialog < Widget
|
|
34
|
+
|
|
35
|
+
# Creates a dialog, using the optional block to set its attributes.
|
|
36
|
+
def initialize &block
|
|
37
|
+
@handle = IupLib.IupFileDlg
|
|
38
|
+
|
|
39
|
+
self.instance_eval &block if block_given?
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Shows the dialog at position x, y.
|
|
43
|
+
def popup x=0, y=0
|
|
44
|
+
IupLib.IupPopup @handle, x, y
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# -- attributes
|
|
48
|
+
|
|
49
|
+
define_attribute :allownew
|
|
50
|
+
define_attribute :dialogtype
|
|
51
|
+
define_attribute :directory
|
|
52
|
+
define_attribute :extfilter
|
|
53
|
+
define_attribute :file
|
|
54
|
+
define_attribute :filter
|
|
55
|
+
define_attribute :filterinfo
|
|
56
|
+
define_attribute :filterused
|
|
57
|
+
define_attribute :multiplefiles
|
|
58
|
+
define_attribute :nochangedir
|
|
59
|
+
define_attribute :nooverwriteprompt
|
|
60
|
+
|
|
61
|
+
def parentdialog parent=nil # :nodoc:
|
|
62
|
+
attribute_reference 'PARENTDIALOG', Dialog, parent
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
define_attribute :showhidden
|
|
66
|
+
define_attribute :showpreview
|
|
67
|
+
|
|
68
|
+
def status # :nodoc:
|
|
69
|
+
status = IupLib.IupGetAttribute(@handle, 'STATUS').first
|
|
70
|
+
status.to_i
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
define_attribute :title
|
|
74
|
+
define_readonly :value
|
|
75
|
+
|
|
76
|
+
# -- callbacks
|
|
77
|
+
|
|
78
|
+
# Called when a file is selected.
|
|
79
|
+
# callback:: takes two arguments, a filename and a status.
|
|
80
|
+
def file_cb callback
|
|
81
|
+
unless callback.arity == 2
|
|
82
|
+
raise ArgumentError, 'file_cb callback must take 2 arguments, a filename, and status'
|
|
83
|
+
end
|
|
84
|
+
cb = Proc.new do |ih, fn_ptr, st_ptr|
|
|
85
|
+
fn = FFI::Pointer.new(fn_ptr).read_string
|
|
86
|
+
st = FFI::Pointer.new(st_ptr).read_string
|
|
87
|
+
callback.call fn, st
|
|
88
|
+
end
|
|
89
|
+
define_callback cb, 'FILE_CB', :ss_i
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
data/lib/wrapped/fill.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# Dynamically fills empty space. Its parent _must_ be an HBox or VBox.
|
|
4
|
+
#
|
|
5
|
+
# == Attributes
|
|
6
|
+
#
|
|
7
|
+
# expand:: <b>read-only</b>, 'horizontal' if in an HBox, or 'vertical' if
|
|
8
|
+
# in a VBox.
|
|
9
|
+
# position:: <b>read-only</b> returns position in pixels within client window
|
|
10
|
+
# as "x,y".
|
|
11
|
+
# rastersize:: Size of the widget, in pixels, value as "widthxheight".
|
|
12
|
+
#
|
|
13
|
+
class Fill < Widget
|
|
14
|
+
|
|
15
|
+
# Creates an instance of Fill.
|
|
16
|
+
# Note that attributes must be set separately, not through a block.
|
|
17
|
+
def initialize
|
|
18
|
+
@handle = IupLib.IupFill
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
define_readonly :expand
|
|
22
|
+
define_readonly :position
|
|
23
|
+
define_attribute :rastersize
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module Iup
|
|
2
|
+
|
|
3
|
+
# A FontDialog allows the user to select a font.
|
|
4
|
+
#
|
|
5
|
+
# == Attributes
|
|
6
|
+
#
|
|
7
|
+
# parentdialog:: This dialog will be always in front of the parent dialog.
|
|
8
|
+
# If the parent is minimized, this dialog is automatically minimized.
|
|
9
|
+
# *Important* Closing the parent will also close the child, but the
|
|
10
|
+
# child dialog's CLOSE_CB method will not be called.
|
|
11
|
+
# previewtext:: The text to use for preview of font selection.
|
|
12
|
+
# status:: <b>read-only</b> returns '1' if 'OK' pressed, or null
|
|
13
|
+
# title:: Title text for the message dialog.
|
|
14
|
+
# value:: Initial value of font for dialog, and return value if 'OK' pressed.
|
|
15
|
+
#
|
|
16
|
+
class FontDialog < Widget
|
|
17
|
+
|
|
18
|
+
# Creates a dialog, using the optional block to set its attributes.
|
|
19
|
+
def initialize &block
|
|
20
|
+
@handle = IupLib.IupFontDlg
|
|
21
|
+
|
|
22
|
+
self.instance_eval &block if block_given?
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Shows the dialog at position x, y.
|
|
26
|
+
def popup x=0, y=0
|
|
27
|
+
IupLib.IupPopup @handle, x, y
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# -- attributes
|
|
31
|
+
|
|
32
|
+
def parentdialog parent=nil #:nodoc:
|
|
33
|
+
attribute_reference 'PARENTDIALOG', Dialog, parent
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
define_attribute :previewtext
|
|
37
|
+
define_readonly :status
|
|
38
|
+
define_attribute :title
|
|
39
|
+
define_attribute :value
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|