Class: Shoes::Swt::Dialog

Inherits:
Object
  • Object
show all
Defined in:
shoes-swt/lib/shoes/swt/dialog.rb

Constant Summary collapse

SWT =
::Swt::SWT
ALERT_STYLE =
SWT::OK | SWT::ICON_INFORMATION
CONFIRM_STYLE =
SWT::YES | SWT::NO | SWT::ICON_QUESTION

Instance Method Summary collapse

Instance Method Details

#alert(msg = '') ⇒ Object



10
11
12
13
# File 'shoes-swt/lib/shoes/swt/dialog.rb', line 10

def alert(msg = '')
  open_message_box ALERT_STYLE, msg
  nil
end

#ask_color(title) ⇒ Object



28
29
30
31
32
33
34
# File 'shoes-swt/lib/shoes/swt/dialog.rb', line 28

def ask_color(title)
  shell = ::Swt::Widgets::Shell.new Shoes.display
  cd = ::Swt::Widgets::ColorDialog.new shell
  cd.setText title
  color = cd.open
  color ? ::Shoes::Color.new(color.red, color.green, color.blue, ::Shoes::Color::OPAQUE) : ::Shoes::Color.new(0, 0, 0, ::Shoes::Color::OPAQUE)
end

#confirm(msg = '') ⇒ Object



15
16
17
18
# File 'shoes-swt/lib/shoes/swt/dialog.rb', line 15

def confirm(msg = '')
  answer_id = open_message_box CONFIRM_STYLE, msg
  confirmed? answer_id
end

#dialog_chooser(title, folder = false, style = :open) ⇒ Object



20
21
22
23
24
25
26
# File 'shoes-swt/lib/shoes/swt/dialog.rb', line 20

def dialog_chooser(title, folder = false, style = :open)
  style = (style == :save ? ::Swt::SWT::SAVE : ::Swt::SWT::OPEN)
  shell = ::Swt::Widgets::Shell.new Shoes.display
  fd = folder ? ::Swt::Widgets::DirectoryDialog.new(shell, style) : ::Swt::Widgets::FileDialog.new(shell, style)
  fd.setText title
  fd.open
end