Class: Iup::ProgressDialog

Inherits:
Widget
  • Object
show all
Includes:
AttributeReference
Defined in:
lib/wrapped/progressdialog.rb

Overview

A dialog to show the progress of an operation.

Attributes

count

n, number of iterations completed so far.

description

The text to show within the dialog, describing operation.

inc

n, write-only increases progress by n.

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.

percent

n, current percent of iterations.

state

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

title

Title text for the progress dialog.

totalcount

n, total number of iterations to complete.

Instance Attribute Summary

Attributes inherited from Widget

#handle

Instance Method Summary collapse

Methods included from AttributeReference

#attribute_reference

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

#define_callback

Constructor Details

#initialize(&block) ⇒ ProgressDialog

Creates an instance of the dialog.

block

optional block to set up the dialog’s attributes.



25
26
27
28
29
30
# File 'lib/wrapped/progressdialog.rb', line 25

def initialize &block
  @handle = IupLib.IupProgressDlg

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

Instance Method Details

#cancel_cb(callback) ⇒ Object

Action generated when the user clicked on the Cancel button.



64
65
66
67
68
69
70
71
72
# File 'lib/wrapped/progressdialog.rb', line 64

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

#close_cb(callback) ⇒ Object

Called right before the dialog is closed.



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

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

#hideObject

Hides the dialog.



33
34
35
# File 'lib/wrapped/progressdialog.rb', line 33

def hide
  IupLib.IupHide @handle
end

#parentdialog(parent = nil) ⇒ Object

:nodoc:



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

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

#resize_cb(callback) ⇒ Object

Action generated when the dialog 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)



89
90
91
92
93
94
95
96
97
# File 'lib/wrapped/progressdialog.rb', line 89

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 an optional (x, y) position.



38
39
40
41
42
43
44
# File 'lib/wrapped/progressdialog.rb', line 38

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.



101
102
103
104
105
106
107
108
109
# File 'lib/wrapped/progressdialog.rb', line 101

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