Class: Object

Inherits:
BasicObject
Includes:
Types
Defined in:
lib/shoes/ruby.rb,
lib/purple_shoes.rb

Instance Method Summary collapse

Instance Method Details

#alert(msg) ⇒ Object



11
12
13
14
15
16
# File 'lib/shoes/ruby.rb', line 11

def alert msg
  shell = Swt::Shell.new Shoes.display
  mb = Swt::MessageBox.new shell, Swt::SWT::OK | Swt::SWT::ICON_INFORMATION
  mb.setMessage msg.to_s
  mb.open
end

#ask(msg, args = {}) ⇒ Object



56
57
58
# File 'lib/shoes/ruby.rb', line 56

def ask msg, args={}
  AskDialog.new(Swt::Shell.new, msg, args).open
end

#ask_color(title = 'Pick a color...') ⇒ Object



48
49
50
51
52
53
54
# File 'lib/shoes/ruby.rb', line 48

def ask_color title = 'Pick a color...'
  shell = Swt::Shell.new Shoes.display
  cd = Swt::ColorDialog.new shell
  cd.setText title
  color = cd.open
  color ? [color.red, color.green, color.blue] : [255, 255, 255]
end

#ask_open_fileObject



25
26
27
# File 'lib/shoes/ruby.rb', line 25

def ask_open_file
  dialog_chooser 'Open File...'
end

#ask_open_folderObject



33
34
35
# File 'lib/shoes/ruby.rb', line 33

def ask_open_folder
  dialog_chooser 'Open Folder...', :folder
end

#ask_save_fileObject



29
30
31
# File 'lib/shoes/ruby.rb', line 29

def ask_save_file
  dialog_chooser 'Save File...'
end

#ask_save_folderObject



37
38
39
# File 'lib/shoes/ruby.rb', line 37

def ask_save_folder
  dialog_chooser 'Save Folder...', :folder
end

#confirm(msg) ⇒ Object



18
19
20
21
22
23
# File 'lib/shoes/ruby.rb', line 18

def confirm msg
  shell = Swt::Shell.new Shoes.display
  mb = Swt::MessageBox.new shell, Swt::SWT::YES | Swt::SWT::NO | Swt::SWT::ICON_QUESTION
  mb.setMessage msg.to_s
  mb.open == Swt::SWT::YES ? true : false
end

#dialog_chooser(title, folder = false, style = Swt::SWT::OPEN) ⇒ Object



41
42
43
44
45
46
# File 'lib/shoes/ruby.rb', line 41

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