Class: Iup::ProgressDialog

Inherits:
Dialog show all
Defined in:
lib/wrapped/progressdialog.rb

Overview

A predefined dialog to show the progress of an operation. It is often used alongside a Iup::Timer, which triggers updates at regular intervals.

Example

dlg = Iup::ProgressDialog.new do |d|
  d.title = "Progress on task ..."
  d.description = "... taking a long time"
  d.totalcount = 100
  d.count = 30
  d.cancel_cb = ->{
    puts "Task cancelled"
    Iup::CLOSE
  }
end
dlg.show

The dialog is meant to be shown using show.

Instance Attribute Summary

Attributes inherited from Widget

#handle

Instance Method Summary collapse

Methods inherited from Dialog

#background, #border, #clientoffset, #clientsize, #close_cb=, #cursor, #cursor=, #defaultenter, #defaultenter=, #defaultesc, #defaultesc=, #expand, #fullscreen, #hide, #icon, #icon=, #map, #maxbox, #menu, #menu=, #menubox, #minbox, #modal, #parentdialog, #parentdialog=, #placement, #popup, #rastersize, #resize, #resize_cb=, #screenposition, #show, #show_cb=, #shrink, #startfocus, #startfocus=, #tip, #title

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 {|_self| ... } ⇒ ProgressDialog

Creates an instance of the dialog. If a block is given, the new instance is yielded to it.

Yields:

  • (_self)

Yield Parameters:



27
28
29
30
31
32
# File 'lib/wrapped/progressdialog.rb', line 27

def initialize
  @handle = IupLib.IupProgressDlg

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

Instance Method Details

#cancel_cb=(callback) ⇒ Object



75
76
77
78
79
80
81
82
83
# File 'lib/wrapped/progressdialog.rb', line 75

def cancel_cb= callback
  unless callback.arity.zero?
    raise ArgumentError, 'cancel_cb callback must take 0 arguments'
  end
  cb = Proc.new do |ih|
    callback.call
  end
  define_callback cb, 'CANCEL_CB', :plain
end

#countObject

:attr: count n, number of iterations completed so far.



39
# File 'lib/wrapped/progressdialog.rb', line 39

define_attribute :count

#descriptionObject

:attr: description The text to show within the dialog, describing operation.



44
# File 'lib/wrapped/progressdialog.rb', line 44

define_attribute :description

#incObject

:attr_writer: inc n, increases progress by n.



49
# File 'lib/wrapped/progressdialog.rb', line 49

define_writer :inc

#percentObject

:attr: percent n, current percent of iterations.



54
# File 'lib/wrapped/progressdialog.rb', line 54

define_attribute :percent

#stateObject

:attr: state current state of the iteration, values ‘idle’ / ‘processing’ / ‘undefined’ / ‘aborted’.



59
# File 'lib/wrapped/progressdialog.rb', line 59

define_attribute :state

#totalcountObject

:attr: totalcount n, total number of iterations to complete.



64
# File 'lib/wrapped/progressdialog.rb', line 64

define_attribute :totalcount