class Iup::Dialog
A Dialog
is a top-level window, containing a single widget.
Attributes¶ ↑
- background
-
RGB colour for background of dialog and children.
- border
-
If set, displays a resize border around dialog.
- clientsize
-
read-only, returns current size of box as “widthxheight”.
- cursor
-
Defines the mouse shape / cursor for the dialog.
- expand
-
Allows container to fill available space in indicated direction. Values 'no' / 'horizontal' / 'vertical' / 'yes'.
- fullscreen
-
'no' / 'yes'.
- maxbox
-
'no' / 'yes', to show maximize box on dialog.
- menubox
-
'no' / 'yes', to show system menu box on dialog.
- minbox
-
'no' / 'yes', to show minimize box on dialog.
- modal
-
read-only Returns modal state of dialog.
- parentdialog
-
Sets/retrieves dialog to use as parent of this dialog.
- placement
-
'normal' / 'maximized' / 'minimized' / 'full'.
- rastersize
-
Size of the dialog, in pixels, value as “widthxheight”.
- resize
-
'no' / 'yes'.
- shrink
-
'no' / 'yes', allows dialog's children to reduce their size if the dialog is made smaller.
- screenposition
-
read-only returns position in pixels on screen as “x,y”.
- size
-
Size of the dialog, in character units, value as “widthxheight”. Can also use: 'full' / 'half' / 'third' / 'quarter' / 'eighth'.
- startfocus
-
Name of widget to gain focus when dialog first shown.
- tip
-
Tooltip string.
- title
-
text displayed as dialog title.
Public Class Methods
Creates a new dialog for given widget.
- widget
-
the child widget to display.
- block
-
optional block to set up attributes.
# File lib/wrapped/dialog.rb, line 40 def initialize widget, &block @handle = IupLib.IupDialog widget.handle # run any provided block on instance, to set up further attributes self.instance_eval &block if block_given? end
Public Instance Methods
Called right before the dialog is closed.
# File lib/wrapped/dialog.rb, line 140 def close_cb callback unless callback.arity.zero? raise ArgumentError, 'close_cb callback must take 0 arguments' end cb = Proc.new do |ih| callback.call end define_callback cb, 'CLOSE_CB', :plain end
Identifies button to activate when 'enter' is pressed. Leave item nil to retrieve current button.
# File lib/wrapped/dialog.rb, line 95 def defaultenter item=nil attribute_reference 'DEFAULTENTER', Button, item end
Identifies button to activate when 'escape' is pressed. Leave item nil to retrieve current button.
# File lib/wrapped/dialog.rb, line 101 def defaultesc item=nil attribute_reference 'DEFAULTESC', Button, item end
Hides the dialog from view.
# File lib/wrapped/dialog.rb, line 48 def hide IupLib.IupHide @handle end
Defines or retrieves icon to use for dialog.
- item
-
optional instance of
ImageWidget
# File lib/wrapped/dialog.rb, line 109 def icon item=nil attribute_reference 'ICON', ImageWidget, item end
Lays out the child widget and its contents, without showign the dialog.
# File lib/wrapped/dialog.rb, line 53 def map IupLib.IupMap @handle self end
Shows the dialog at position (x, y).
# File lib/wrapped/dialog.rb, line 59 def popup x, y IupLib.IupPopup @handle, x.to_i, y.to_i end
Action generated when the canvas size is changed. resize_cb
a 2-argument callback: (width, height).
- width
-
internal width of canvas (client width)
- height
-
internal height of canvas (client height)
# File lib/wrapped/dialog.rb, line 154 def resize_cb callback unless callback.arity == 2 raise ArgumentError, 'resize_cb callback must take 2 arguments: (width, height)' end cb = Proc.new do |ih, width, height| callback.call width, height end define_callback cb, 'RESIZE_CB', :ii_i end
Shows the dialog at the default screen position, or at (x, y) if specified.
# File lib/wrapped/dialog.rb, line 65 def show x=nil, y=nil if x.nil? and y.nil? IupLib.IupShow @handle else IupLib.IupShowXY @handle, x.to_i, y.to_i end end
Called right after the dialog is shown, hidden, maximized, minimized or restored from minimized/maximized. Callback takes one argument, the state of the change.
# File lib/wrapped/dialog.rb, line 166 def show_cb callback unless callback.arity == 1 raise ArgumentError, 'show_cb callback must take 1 argument: (state)' end cb = Proc.new do |ih, state| callback.call state end define_callback cb, 'SHOW_CB', :i_i end