Class: Iup::FileDialog
Overview
A FileDialog is a predefined dialog for selecting files or a directory. The dialog can only be shown using the popup function.
Attributes
- allownew
-
If set, indicates if non-existent filenames are accepted. Values as ‘yes’ / ‘no’ - defaults to ‘no’.
- dialogtype
-
‘open’ / ‘save’ / ‘dir’
- directory
-
Initial directory
- extfilter
-
Defines filters, e.g. “Text files|.txt;.doc|Image files|.gif;.jpg;*.bmp|”, has priority over
filterinfoandfilter. - file
-
Name of file. Will be used instead of
dictionaryif it contains a complete path. - filter
-
Filter to use, e.g. “.C;.LED;test.*”.
- filterinfo
-
Information about the
filter, e.g. “C files”. - filterused
-
n, index of filter from
extfilterthat was used. Index counts from 1. - multiplefiles
-
‘no’ / ‘yes’, set to allow selection of multiple files.
- nochangedir
-
‘yes’ / ‘no’, if set, restores current directory after dialog is closed.
- nooverwriteprompt
-
‘no’ / ‘yes’, if set, prompts before overwriting existing files.
- parentdialog
-
This dialog will be always in front of the parent dialog. If the parent is minimized, this dialog is automatically minimized. Important Closing the parent will also close the child, but the child dialog’s CLOSE_CB method will not be called.
- showhidden
-
‘no’ / ‘yes’, if set, shows hidden files.
- showpreview
-
‘no’ / ‘yes’, if set, shows a preview area for file.
- status
-
read-only Returns an integer: 1 for new file, 0 for existing file/directory, for -1 for cancelled.
- title
-
Title text for the file dialog.
- value
-
read-only Name of file(s) selected.
Instance Attribute Summary
Attributes inherited from Widget
Instance Method Summary collapse
-
#file_cb(callback) ⇒ Object
Called when a file is selected.
-
#initialize(&block) ⇒ FileDialog
constructor
Creates a dialog, using the optional block to set its attributes.
-
#parentdialog(parent = nil) ⇒ Object
:nodoc:.
-
#popup(x = 0, y = 0) ⇒ Object
Shows the dialog at position x, y.
-
#status ⇒ Object
:nodoc:.
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 AttributeBuilders
#define_attribute, #define_id_attribute, #define_id_readonly, #define_id_writeonly, #define_property_attribute, #define_property_writeonly, #define_readonly, #define_writeonly
Methods included from CallbackSetter
Constructor Details
#initialize(&block) ⇒ FileDialog
Creates a dialog, using the optional block to set its attributes.
36 37 38 39 40 |
# File 'lib/wrapped/filedialog.rb', line 36 def initialize &block @handle = IupLib.IupFileDlg self.instance_eval &block if block_given? end |
Instance Method Details
#file_cb(callback) ⇒ Object
Called when a file is selected.
- callback
-
takes two arguments, a filename and a status.
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/wrapped/filedialog.rb', line 80 def file_cb callback unless callback.arity == 2 raise ArgumentError, 'file_cb callback must take 2 arguments, a filename, and status' end cb = Proc.new do |ih, fn_ptr, st_ptr| fn = FFI::Pointer.new(fn_ptr).read_string st = FFI::Pointer.new(st_ptr).read_string callback.call fn, st end define_callback cb, 'FILE_CB', :ss_i end |
#parentdialog(parent = nil) ⇒ Object
:nodoc:
61 62 63 |
# File 'lib/wrapped/filedialog.rb', line 61 def parentdialog parent=nil # :nodoc: attribute_reference 'PARENTDIALOG', Dialog, parent end |
#popup(x = 0, y = 0) ⇒ Object
Shows the dialog at position x, y.
43 44 45 |
# File 'lib/wrapped/filedialog.rb', line 43 def popup x=0, y=0 IupLib.IupPopup @handle, x, y end |
#status ⇒ Object
:nodoc:
68 69 70 71 |
# File 'lib/wrapped/filedialog.rb', line 68 def status # :nodoc: status = IupLib.IupGetAttribute(@handle, 'STATUS').first status.to_i end |