Class: Iup::Dialog
- Includes:
- AttributeReference, DragDropAttributes
- Defined in:
- lib/wrapped/dialog.rb
Overview
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.
Instance Attribute Summary
Attributes inherited from Widget
Instance Method Summary collapse
-
#close_cb(callback) ⇒ Object
Called right before the dialog is closed.
-
#cursor(image = nil) ⇒ Object
:nodoc:.
-
#defaultenter(item = nil) ⇒ Object
Identifies button to activate when ‘enter’ is pressed.
-
#defaultesc(item = nil) ⇒ Object
Identifies button to activate when ‘escape’ is pressed.
-
#hide ⇒ Object
Hides the dialog from view.
-
#icon(item = nil) ⇒ Object
Defines or retrieves icon to use for dialog.
-
#initialize(widget, &block) ⇒ Dialog
constructor
Creates a new dialog for given widget.
-
#map ⇒ Object
Lays out the child widget and its contents, without showign the dialog.
-
#menu(item = nil) ⇒ Object
Assigns given item as the menu for this dialog.
-
#parentdialog(parent = nil) ⇒ Object
:nodoc:.
-
#popup(x, y) ⇒ Object
Shows the dialog at position (x, y).
-
#resize_cb(callback) ⇒ Object
resize_cb a 2-argument callback: (width, height).
-
#show(x = nil, y = nil) ⇒ Object
Shows the dialog at the default screen position, or at (x, y) if specified.
-
#show_cb(callback) ⇒ Object
Called right after the dialog is shown, hidden, maximized, minimized or restored from minimized/maximized.
-
#startfocus(item = nil) ⇒ Object
:nodoc:.
Methods included from AttributeReference
Methods included from DragDropAttributes
#dragbegin_cb, #dragdata_cb, #dragdatasize_cb, #dragend_cb, #dropdata_cb, #dropmotion_cb
Methods included from AttributeBuilders
#define_attribute, #define_id_attribute, #define_id_readonly, #define_id_writeonly, #define_property_attribute, #define_property_writeonly, #define_readonly, #define_writeonly
Methods inherited from Widget
#assign_handle, #enterwindow_cb, #getfocus_cb, #help_cb, #k_any, #killfocus_cb, #leavewindow_cb, #map_cb, #open_controls, #unmap_cb
Methods included from CallbackSetter
Constructor Details
#initialize(widget, &block) ⇒ Dialog
Creates a new dialog for given widget.
- widget
-
the child widget to display.
- block
-
optional block to set up attributes.
40 41 42 43 44 45 |
# File 'lib/wrapped/dialog.rb', line 40 def initialize , &block @handle = IupLib.IupDialog .handle # run any provided block on instance, to set up further attributes self.instance_eval &block if block_given? end |
Instance Method Details
#close_cb(callback) ⇒ Object
Called right before the dialog is closed.
140 141 142 143 144 145 146 147 148 |
# 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 |
#cursor(image = nil) ⇒ Object
:nodoc:
81 82 83 |
# File 'lib/wrapped/dialog.rb', line 81 def cursor image=nil # :nodoc: attribute_reference 'CURSOR', ImageWidget, image end |
#defaultenter(item = nil) ⇒ Object
Identifies button to activate when ‘enter’ is pressed. Leave item nil to retrieve current button.
95 96 97 |
# File 'lib/wrapped/dialog.rb', line 95 def defaultenter item=nil attribute_reference 'DEFAULTENTER', Button, item end |
#defaultesc(item = nil) ⇒ Object
Identifies button to activate when ‘escape’ is pressed. Leave item nil to retrieve current button.
101 102 103 |
# File 'lib/wrapped/dialog.rb', line 101 def defaultesc item=nil attribute_reference 'DEFAULTESC', Button, item end |
#hide ⇒ Object
Hides the dialog from view.
48 49 50 |
# File 'lib/wrapped/dialog.rb', line 48 def hide IupLib.IupHide @handle end |
#icon(item = nil) ⇒ Object
Defines or retrieves icon to use for dialog.
- item
-
optional instance of ImageWidget
109 110 111 |
# File 'lib/wrapped/dialog.rb', line 109 def icon item=nil attribute_reference 'ICON', ImageWidget, item end |
#map ⇒ Object
Lays out the child widget and its contents, without showign the dialog.
53 54 55 56 |
# File 'lib/wrapped/dialog.rb', line 53 def map IupLib.IupMap @handle self end |
#menu(item = nil) ⇒ Object
Assigns given item as the menu for this dialog. item may be an instance of Menu, or the string name for a menu.
117 118 119 |
# File 'lib/wrapped/dialog.rb', line 117 def item=nil attribute_reference 'MENU', Menu, item end |
#parentdialog(parent = nil) ⇒ Object
:nodoc:
125 126 127 |
# File 'lib/wrapped/dialog.rb', line 125 def parentdialog parent=nil # :nodoc: attribute_reference 'PARENTDIALOG', Dialog, parent end |
#popup(x, y) ⇒ Object
Shows the dialog at position (x, y).
59 60 61 |
# File 'lib/wrapped/dialog.rb', line 59 def popup x, y IupLib.IupPopup @handle, x.to_i, y.to_i end |
#resize_cb(callback) ⇒ Object
resize_cb a 2-argument callback: (width, height).
- width
-
internal width of canvas (client width)
- height
-
internal height of canvas (client height)
154 155 156 157 158 159 160 161 162 |
# 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 |
#show(x = nil, y = nil) ⇒ Object
Shows the dialog at the default screen position, or at (x, y) if specified.
65 66 67 68 69 70 71 |
# 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 |
#show_cb(callback) ⇒ Object
Called right after the dialog is shown, hidden, maximized, minimized or restored from minimized/maximized. Callback takes one argument, the state of the change.
166 167 168 169 170 171 172 173 174 |
# 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 |
#startfocus(item = nil) ⇒ Object
:nodoc:
133 134 135 |
# File 'lib/wrapped/dialog.rb', line 133 def startfocus item=nil # :nodoc: attribute_reference 'STARTFOCUS', Widget, item end |