Class: Iup::Dialog

Inherits:
Widget show all
Includes:
AttributeReference, DragDropAttributes
Defined in:
lib/wrapped/dialog.rb

Overview

A top-level window, containing a single widget. Supports standard window decorations and a menu.

Example

The following example displays a label widget within the dialog, setting the dialog’s title and size before showing it.

Iup::Dialog.new(label) do |d|
  d.title = " ... from IUP"
  d.size = "150x50"
end.show

Also see: Menu.

Direct Known Subclasses

ColorDialog, FileDialog, ProgressDialog

Instance Attribute Summary

Attributes inherited from Widget

#handle

Instance Method Summary collapse

Methods included from AttributeReference

#attribute_reference

Methods included from DragDropAttributes

#dragbegin_cb=, #dragdata_cb=, #dragdatasize_cb=, #dragend_cb=, #dragsource, #dragsourcemove, #dragtypes, #dropdata_cb=, #dropmotion_cb=, #droptarget, #droptypes

Methods included from AttributeBuilders

#define_attribute, #define_id_attribute, #define_id_reader, #define_id_writer, #define_property_attribute, #define_property_reader, #define_property_writer, #define_reader, #define_writer

Methods inherited from Widget

#active, #assign_handle, #bgcolor, #destroy, #enterwindow_cb=, #fgcolor, #font, #getfocus_cb=, #help_cb=, #k_any=, #killfocus_cb=, #leavewindow_cb=, #map_cb=, #maxsize, #minsize, #open_controls, #size, #unmap_cb=, #visible, #wid, #zorder

Methods included from CallbackSetter

#define_callback

Constructor Details

#initialize(widget) {|_self| ... } ⇒ Dialog

Creates a new dialog for given widget. If a block is given, the new instance is yielded to it.

  • widget - the child widget to display.

Use show to display the dialog after initialisation; some widgets require the dialog to be mapped first, and then shown after the widget is initialised.

Yields:

  • (_self)

Yield Parameters:

  • _self (Iup::Dialog)

    the object that the method was called on



29
30
31
32
33
34
# File 'lib/wrapped/dialog.rb', line 29

def initialize widget
  @handle = IupLib.IupDialog(widget.handle)

  # run any provided block on instance, to set up further attributes
  yield self if block_given? 
end

Instance Method Details

#backgroundObject

:attr: background RGB color for background of dialog and children.



73
# File 'lib/wrapped/dialog.rb', line 73

define_attribute :background

#borderObject

:attr: border If set, displays a resize border around dialog.



78
# File 'lib/wrapped/dialog.rb', line 78

define_attribute :border

#clientoffsetObject

:attr_reader: clientoffset returns current offset of box in its client as “widthxheight”.



83
# File 'lib/wrapped/dialog.rb', line 83

define_reader :clientoffset

#clientsizeObject

:attr_reader: clientsize returns current size of box as “widthxheight”.



88
# File 'lib/wrapped/dialog.rb', line 88

define_reader :clientsize

#close_cb=(callback) ⇒ Object



263
264
265
266
267
268
269
270
271
# File 'lib/wrapped/dialog.rb', line 263

def close_cb= callback # :nodoc:
  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

#cursorObject



95
96
97
# File 'lib/wrapped/dialog.rb', line 95

def cursor
  attribute_reference('CURSOR', ImageWidget, nil)
end

#cursor=(image) ⇒ Object

:nodoc:



99
100
101
# File 'lib/wrapped/dialog.rb', line 99

def cursor= image # :nodoc:
  attribute_reference('CURSOR', ImageWidget, image)
end

#defaultenterObject



137
138
139
# File 'lib/wrapped/dialog.rb', line 137

def defaultenter
  attribute_reference('DEFAULTENTER', Button, nil)
end

#defaultenter=(item) ⇒ Object

:nodoc:



141
142
143
# File 'lib/wrapped/dialog.rb', line 141

def defaultenter= item # :nodoc:
  attribute_reference('DEFAULTENTER', Button, item)
end

#defaultescObject



150
151
152
# File 'lib/wrapped/dialog.rb', line 150

def defaultesc
  attribute_reference('DEFAULTESC', Button, nil)
end

#defaultesc=(item) ⇒ Object

:nodoc:



154
155
156
# File 'lib/wrapped/dialog.rb', line 154

def defaultesc= item # :nodoc:
  attribute_reference('DEFAULTESC', Button, item)
end

#expandObject

:attr: expand Allows container to fill available space in indicated direction. Values ‘no’ / ‘horizontal’ / ‘vertical’ / ‘yes’.



107
# File 'lib/wrapped/dialog.rb', line 107

define_attribute :expand

#fullscreenObject

:attr: fullscreen ‘no’ / ‘yes’.



161
# File 'lib/wrapped/dialog.rb', line 161

define_attribute :fullscreen

#hideObject

Hides the dialog from view.



37
38
39
# File 'lib/wrapped/dialog.rb', line 37

def hide
  IupLib.IupHide @handle
end

#iconObject



168
169
170
# File 'lib/wrapped/dialog.rb', line 168

def icon
  attribute_reference('ICON', ImageWidget, nil)
end

#icon=(item) ⇒ Object

:nodoc:



172
173
174
# File 'lib/wrapped/dialog.rb', line 172

def icon= item # :nodoc:
  attribute_reference('ICON', ImageWidget, item)
end

#mapObject

Lays out the child widget and its contents, without showing the dialog.



42
43
44
45
# File 'lib/wrapped/dialog.rb', line 42

def map
  IupLib.IupMap @handle
  self
end

#maxboxObject

:attr: maxbox ‘no’ / ‘yes’, to show maximize box on dialog.



179
# File 'lib/wrapped/dialog.rb', line 179

define_attribute :maxbox



187
188
189
# File 'lib/wrapped/dialog.rb', line 187

def menu
  attribute_reference('MENU', Menu, nil)
end

:nodoc:



191
192
193
# File 'lib/wrapped/dialog.rb', line 191

def menu= item # :nodoc:
  attribute_reference('MENU', Menu, item)
end

:attr: menubox ‘no’ / ‘yes’, to show system menu box on dialog.



198
# File 'lib/wrapped/dialog.rb', line 198

define_attribute :menubox

#minboxObject

:attr: minbox ‘no’ / ‘yes’, to show minimize box on dialog.



203
# File 'lib/wrapped/dialog.rb', line 203

define_attribute :minbox

:attr_reader: modal Returns modal state of dialog.



208
# File 'lib/wrapped/dialog.rb', line 208

define_reader :modal

#parentdialogObject



218
219
220
# File 'lib/wrapped/dialog.rb', line 218

def parentdialog 
  attribute_reference('PARENTDIALOG', Dialog, nil)
end

#parentdialog=(parent) ⇒ Object

:nodoc:



222
223
224
# File 'lib/wrapped/dialog.rb', line 222

def parentdialog= parent # :nodoc:
  attribute_reference('PARENTDIALOG', Dialog, parent)
end

#placementObject

:attr: placement ‘normal’ / ‘maximized’ / ‘minimized’ / ‘full’.



229
# File 'lib/wrapped/dialog.rb', line 229

define_attribute :placement

Shows the dialog at position (x, y).



50
51
52
# File 'lib/wrapped/dialog.rb', line 50

def popup x=nil, y=nil
  IupLib.IupPopup @handle, x.to_i, y.to_i
end

#rastersizeObject

:attr: rastersize Size of the dialog, in pixels, value as “widthxheight”.



112
# File 'lib/wrapped/dialog.rb', line 112

define_attribute :rastersize

#resizeObject

:attr: resize ‘no’ / ‘yes’.



234
# File 'lib/wrapped/dialog.rb', line 234

define_attribute :resize

#resize_cb=(callback) ⇒ Object



281
282
283
284
285
286
287
288
289
# File 'lib/wrapped/dialog.rb', line 281

def resize_cb= callback # :nodoc:
  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

#screenpositionObject

:attr_reader: screenposition returns position in pixels on screen as “x,y”.



117
# File 'lib/wrapped/dialog.rb', line 117

define_reader :screenposition

#show(x = nil, y = nil) ⇒ Object

Shows the dialog at the default screen position, or at (x, y) if specified.



58
59
60
61
62
63
64
# File 'lib/wrapped/dialog.rb', line 58

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



299
300
301
302
303
304
305
306
307
# File 'lib/wrapped/dialog.rb', line 299

def show_cb= callback #:nodoc:
  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

#shrinkObject

:attr: shrink ‘no’ / ‘yes’, allows dialog’s children to reduce their size if the dialog is made smaller.



240
# File 'lib/wrapped/dialog.rb', line 240

define_attribute :shrink

#startfocusObject



247
248
249
# File 'lib/wrapped/dialog.rb', line 247

def startfocus
  attribute_reference('STARTFOCUS', Widget, nil)
end

#startfocus=(item) ⇒ Object

:nodoc:



251
252
253
# File 'lib/wrapped/dialog.rb', line 251

def startfocus= item # :nodoc:
  attribute_reference('STARTFOCUS', Widget, item)
end

#tipObject

:attr: tip Tooltip string.



122
# File 'lib/wrapped/dialog.rb', line 122

define_attribute :tip

#titleObject

:attr: title Displayed as dialog title.



127
# File 'lib/wrapped/dialog.rb', line 127

define_attribute :title