Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Jruby SWT Implementation. First Iteration. Shoes::App has Window with…

… Flow, will contain Button, handle click-event
  • Loading branch information...
commit eb2cb839600ef8469adf0dbd8819254118d417ff 1 parent 38b04de
pfitzgibbons authored
Showing with 1,292 additions and 715 deletions.
  1. +6 −0 .gitignore
  2. +2 −0  .rspec
  3. +1 −1  .rvmrc
  4. +15 −6 Gemfile
  5. +9 −0 Gemfile.lock
  6. +3 −3 Rakefile
  7. +0 −22 lib/brown_shoes.rb
  8. +0 −73 lib/brown_shoes/app.rb
  9. +0 −20 lib/brown_shoes/elements/button.rb
  10. +0 −19 lib/brown_shoes/elements/stack.rb
  11. +202 −0 lib/log4j/LICENSE
  12. +5 −0 lib/log4j/NOTICE
  13. BIN  lib/log4j/log4j-1.2.16.jar
  14. +554 −0 lib/red_shoes.rb
  15. 0  lib/{shoes → red_shoes}/cache.rb
  16. 0  lib/{shoes → red_shoes}/chipmunk.rb
  17. 0  lib/{shoes → red_shoes}/data.rb
  18. 0  lib/{shoes → red_shoes}/help.rb
  19. 0  lib/{shoes → red_shoes}/image.rb
  20. 0  lib/{shoes → red_shoes}/inspect.rb
  21. 0  lib/{shoes → red_shoes}/log.rb
  22. 0  lib/{shoes → red_shoes}/minitar.rb
  23. 0  lib/{shoes → red_shoes}/override.rb
  24. 0  lib/{shoes → red_shoes}/pack.rb
  25. 0  lib/{shoes → red_shoes}/search.rb
  26. 0  lib/{shoes → red_shoes}/setup.rb
  27. 0  lib/{shoes → red_shoes}/shy.rb
  28. 0  lib/{shoes → red_shoes}/shybuilder.rb
  29. 0  lib/{shoes → red_shoes}/version.rb
  30. +29 −542 lib/shoes.rb
  31. +41 −0 lib/shoes/app.rb
  32. +15 −0 lib/shoes/button.rb
  33. +13 −0 lib/shoes/composite.rb
  34. +13 −0 lib/shoes/composites.rb
  35. +1 −0  lib/shoes/config_logger.rb
  36. +6 −0 lib/shoes/element.rb
  37. +46 −0 lib/shoes/elements.rb
  38. 0  lib/{brown_shoes → shoes}/elements/check.rb
  39. 0  lib/{brown_shoes → shoes}/elements/edit_box.rb
  40. 0  lib/{brown_shoes → shoes}/elements/edit_line.rb
  41. 0  lib/{brown_shoes → shoes}/elements/element.rb
  42. 0  lib/{brown_shoes → shoes}/elements/flow.rb
  43. 0  lib/{brown_shoes → shoes}/elements/image.rb
  44. +20 −0 lib/shoes/elements/stack.rb
  45. +18 −0 lib/shoes/flow.rb
  46. +8 −0 lib/shoes/stack.rb
  47. +11 −0 lib/shoes/swt_constants.rb
  48. +34 −0 lib/shoes/window.rb
  49. BIN  lib/swt.jar
  50. +6 −0 log4j.properties
  51. +1 −1  req/hpricot/lib/hpricot.rb
  52. +19 −0 rspec
  53. +10 −0 shooes
  54. +15 −0 shooesd
  55. +0 −5 spec/brown_shoes_spec.rb
  56. +32 −0 spec/shoes/app_spec.rb
  57. 0  spec/{brown_shoes → shoes}/check_spec.rb
  58. 0  spec/{brown_shoes → shoes}/element_methods_spec.rb
  59. 0  spec/{brown_shoes → shoes}/elementary_button_spec.rb
  60. 0  spec/{brown_shoes → shoes}/image_spec.rb
  61. 0  spec/{brown_shoes → shoes}/images/shoe.jpg
  62. +25 −0 spec/shoes/window_spec.rb
  63. +29 −0 spec/shoes_spec.rb
  64. +5 −8 spec/spec_helper.rb
  65. +74 −0 swt_info/ex1.rb
  66. 0  swt_info/swt_example.rb
  67. +1 −1  testing/image_test.rb
  68. +1 −1  testing/interpreter.rb
  69. +1 −1  testing/stevescalc.rb
  70. +21 −12 testing/testing.rb
View
6 .gitignore
@@ -13,6 +13,12 @@ tmtags
## VIM
*.swp
+## BUNDLER
+.bundle
+
+## INTELLIJ/RUBYMINE
+.idea
+
## PROJECT::GENERAL
coverage
rdoc
View
2  .rspec
@@ -0,0 +1,2 @@
+-c
+-f d
View
2  .rvmrc
@@ -1 +1 @@
-rvm 1.9.2@shoes
+rvm use jruby@shoes
View
21 Gemfile
@@ -1,9 +1,18 @@
source "http://rubygems.org"
-gem "mechanize"
-gem "gherkin"
-gem "cucumber"
-gem "rspec"
-gem "rake"
-gem "shoes-cucumber"
+gem 'facets'
+gem 'log4jruby'
+
+group :development do
+
+end
+
+group :test do
+ gem "mechanize"
+ gem "gherkin"
+ gem "cucumber"
+ gem "rspec"
+ gem "rake"
+ gem "shoes-cucumber"
+end
View
9 Gemfile.lock
@@ -9,9 +9,14 @@ GEM
json (>= 1.4.6)
term-ansicolor (>= 1.0.6)
diff-lcs (1.1.3)
+ facets (2.9.2)
gherkin (2.5.1)
json (>= 1.4.6)
+ gherkin (2.5.1-java)
+ json (>= 1.4.6)
json (1.6.1)
+ json (1.6.1-java)
+ log4jruby (0.4.0)
mechanize (2.0.1)
net-http-digest_auth (~> 1.1, >= 1.1.1)
net-http-persistent (~> 1.8)
@@ -20,6 +25,7 @@ GEM
net-http-digest_auth (1.1.1)
net-http-persistent (1.9)
nokogiri (1.5.0)
+ nokogiri (1.5.0-java)
rake (0.9.2)
rspec (2.6.0)
rspec-core (~> 2.6.0)
@@ -40,11 +46,14 @@ GEM
nokogiri (>= 1.4.4)
PLATFORMS
+ java
ruby
DEPENDENCIES
cucumber
+ facets
gherkin
+ log4jruby
mechanize
rake
rspec
View
6 Rakefile
@@ -508,11 +508,11 @@ require 'rake'
begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
- gem.name = "brown_shoes"
+ gem.name = "shoes"
gem.summary = %Q{JRuby implementation of shoes}
gem.description = %Q{JRuby implementation of shoes}
gem.email = "stwerner@vt.edu"
- gem.homepage = "http://github.com/scottw/brown_shoes"
+ gem.homepage = "http://github.com/scottw/shoes"
gem.authors = ["Scott Werner"]
gem.add_development_dependency "rspec", ">= 1.2.9"
gem.files.include('lib/**/*.rb')
@@ -544,7 +544,7 @@ Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
rdoc.rdoc_dir = 'rdoc'
- rdoc.title = "brown_shoes #{version}"
+ rdoc.title = "shoes #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
View
22 lib/brown_shoes.rb
@@ -1,22 +0,0 @@
-require 'java'
-
-require 'rubygems'
-require 'require_all'
-
-require_rel 'brown_shoes/app'
-require_rel 'brown_shoes/elements/element'
-require_rel 'brown_shoes/elements/button'
-require_rel 'brown_shoes/elements/stack'
-require_rel 'brown_shoes/elements/flow'
-require_rel 'brown_shoes/elements/edit_line'
-require_rel 'brown_shoes/elements/edit_box'
-require_rel 'brown_shoes/elements/check'
-require_rel 'brown_shoes/elements/image'
-
-module Shoes
-
-def self.app(opts={}, &blk)
- Shoes::App.new(opts, &blk)
-end
-
-end
View
73 lib/brown_shoes/app.rb
@@ -1,73 +0,0 @@
-module Shoes
-class App
-
- attr_accessor :elements,:frame
-
- def initialize(opts={}, &blk)
- @elements = {}
- @frame = javax.swing.JFrame.new()
-
- @global_panel = javax.swing.JPanel.new()
- @current_panel = @global_panel
- flow(opts, &blk)
-
-
- @frame.add(@global_panel)
- @frame.setDefaultCloseOperation(javax.swing.JFrame::EXIT_ON_CLOSE)
- @frame.pack()
- if(opts[:width] && opts[:height])
- @frame.setSize(opts[:width], opts[:height])
- end
- @frame.set_visible(true)
- end
-
- def button(opts={}, &blk)
-
- button = Button.new(@current_panel,opts, &blk)
- @elements[button.identifier] = button
- button
- end
-
- def image(path, opts={})
- image = Image.new(path, @current_panel, opts)
- @elements[image.identifier] = image
- image
- end
-
- def edit_line(opts={})
- eline = Edit_line.new(@current_panel, opts)
- @elements[eline.identifier] = eline
- eline
- end
-
- def text_box(opts={})
- tbox = Text_box.new(@current_panel, opts)
- @elements[tbox.identifier] = tbox
- tbox
- end
-
- def check(opts={}, &blk)
- cbox = Check.new(@current_panel, opts)
- @elements[cbox.identifier] = cbox
- cbox
- end
-
- def stack(opts={}, &blk)
- tstack = Stack.new(opts)
- layout(tstack, &blk)
- end
-
- def flow(opts={}, &blk)
- tflow = Flow.new(opts)
- layout(tflow, &blk)
- end
-
- def layout(layer, &blk)
- parent = @current_panel
- @current_panel = layer.panel
- instance_eval &blk
- parent.add(@current_panel)
- @current_panel = parent
- end
-end
-end
View
20 lib/brown_shoes/elements/button.rb
@@ -1,20 +0,0 @@
-module Shoes
-class Button < Element
-
- attr_accessor :button
-
- def initialize(parent,opts={}, &blk)
- super(opts)
- opts[:text] ||= "Button"
- @button = javax.swing.JButton.new(opts[:text])
- @button.add_action_listener(&blk) unless blk.nil?
- parent.add(@button)
- return @button
- end
-
- def to_java
- @button.to_java
- end
-
-end
-end
View
19 lib/brown_shoes/elements/stack.rb
@@ -1,19 +0,0 @@
-module Shoes
-class Stack < Element
- java_import "javax.swing.JPanel"
- java_import "javax.swing.BoxLayout"
- java_import "java.awt.Dimension"
-
- attr_accessor :panel
- def initialize(opts={})
- super(opts)
- @panel = JPanel.new()
- layout = BoxLayout.new(@panel, BoxLayout::PAGE_AXIS)
- @panel.set_layout(layout)
- if(opts[:width] && opts[:height])
- @panel.set_preferred_size(java.awt.Dimension.new(opts[:width], opts[:height]))
- end
- end
-
-end
-end
View
202 lib/log4j/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 1999-2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
View
5 lib/log4j/NOTICE
@@ -0,0 +1,5 @@
+Apache log4j
+Copyright 2007 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
View
BIN  lib/log4j/log4j-1.2.16.jar
Binary file not shown
View
554 lib/red_shoes.rb
@@ -0,0 +1,554 @@
+# -*- encoding: utf-8 -*-
+#
+# lib/shoes.rb
+# The Shoes base app, both a demonstration and the learning tool for
+# using Shoes.
+#
+ARGV.delete_if { |x| x =~ /-psn_/ }
+
+class Encoding
+ %w[UTF_7 UTF_16BE UTF_16LE UTF_32BE UTF_32LE].each do |enc|
+ eval "class #{enc};end" unless const_defined? enc.to_sym
+ end
+end
+
+require 'open-uri'
+require 'optparse'
+require 'resolv-replace' if RUBY_PLATFORM =~ /win/
+require_relative 'shoes/inspect'
+require_relative 'shoes/cache'
+if Object.const_defined? :Shoes
+ require_relative 'shoes/image'
+end
+require_relative 'shoes/shybuilder'
+
+def Shoes.hook; end
+
+class Encoding
+ %w[ASCII_8BIT UTF_16BE UTF_16LE UTF_32BE UTF_32LE US_ASCII].each do |ec|
+ eval "#{ec} = '#{ec.sub '_', '-'}'"
+ end unless RUBY_PLATFORM =~ /linux/ or RUBY_PLATFORM =~ /darwin/
+end
+
+class Range
+ def rand
+ conv = (Integer === self.end && Integer === self.begin ? :to_i : :to_f)
+ ((Kernel.rand * (self.end - self.begin)) + self.begin).send(conv)
+ end
+end
+
+unless Time.respond_to? :today
+ def Time.today
+ t = Time.now
+ t - (t.to_i % 86400)
+ end
+end
+
+class Shoes
+ RELEASES = %w[Curious Raisins Policeman]
+
+ NotFound = proc do
+ para "404 NOT FOUND, GUYS!"
+ end
+
+ class << self; attr_accessor :locale, :language end
+ @locale = ENV["SHOES_LANG"] || ENV["LC_MESSAGES"] || ENV["LC_ALL"] || ENV["LANG"] || "C"
+ @language = @locale[/^(\w{2})_/, 1] || "en"
+
+ @mounts = []
+
+ OPTS = OptionParser.new do |opts|
+ opts.banner = "Usage: shoes [options] (app.rb or app.shy)"
+
+ opts.on("-m", "--manual",
+ "Open the built-in manual.") do
+ show_manual
+ end
+
+ opts.on("-p", "--package",
+ "Package a Shoes app for Windows, OS X and Linux.") do |s|
+ make_pack
+ end
+
+ opts.on("-g", "--gem",
+ "Passes commands to RubyGems.") do
+ require 'shoes/setup'
+ require 'rubygems/gem_runner'
+ Gem::GemRunner.new.run(ARGV)
+ raise SystemExit, ""
+ end
+
+ opts.on("--manual-html DIRECTORY", "Saves the manual to a directory as HTML.") do |dir|
+ manual_as :html, dir
+ raise SystemExit, "HTML manual in: #{dir}"
+ end
+
+ opts.on("--install MODE SRC DEST", "Installs a file.") do |mode|
+ src, dest = ARGV
+ FileUtils.install src, dest, :mode => mode.to_i(8), :preserve => true
+ raise SystemExit, ""
+ end
+
+ opts.on("--nolayered", "No WS_EX_LAYERED style option.") do
+ $NOLAYERED = 1
+ Shoes.args!
+ end
+
+ opts.on_tail("-v", "--version", "Display the version info.") do
+ raise SystemExit, File.read("#{DIR}/VERSION.txt").strip
+ end
+
+ opts.on_tail("-h", "--help", "Show this message") do
+ raise SystemExit, opts.to_s
+ end
+ end
+
+ class SettingUp < StandardError; end
+
+ @setups = {}
+
+ def self.setup &blk
+ require 'shoes/setup'
+ line = caller[0]
+ return if @setups[line]
+ script = line[/^(.+?):/, 1]
+ set = Shoes::Setup.new(script, &blk)
+ @setups[line] = true
+ unless set.no_steps?
+ raise SettingUp
+ end
+ end
+
+ def self.show_selector
+ fname = ask_open_file
+ Shoes.visit(fname) if fname
+ end
+
+ def self.package_app
+ fname = ask_open_file
+ return false unless fname
+ start_shy_builder fname
+ end
+
+ def self.splash
+ font "#{DIR}/fonts/Lacuna.ttf"
+ Shoes.app :width => 400, :height => 300, :resizable => false do
+ style(Para, :align => "center", :weight => "bold", :font => "Lacuna Regular", :size => 13)
+ style(Link, :stroke => yellow, :underline => nil)
+ style(LinkHover, :stroke => yellow, :fill => nil)
+
+ x1 = 77; y1 = 122
+ x2 = 148; y2 = -122
+ x3 = 245; y3 = 0
+
+ nofill
+ strokewidth 40.0
+
+ @waves = stack :top => 0, :left => 0
+
+ require 'shoes/search'
+ require 'shoes/help'
+
+ stack :margin => 18 do
+ para "Welcome to", :stroke => "#DFA", :margin => 0
+ para "SHOES", :size => 48, :stroke => "#DFA", :margin_top => 0
+ stack do
+ background black(0.2), :curve => 8
+ para link("Open an App.") { Shoes.show_selector and close }, :margin => 10, :margin_bottom => 4
+ #para link("Package an App.") { Shoes.package_app and close }, :margin => 10, :margin_bottom => 4
+ para link("Package an App.") { Shoes.make_pack and close }, :margin => 10, :margin_bottom => 4
+ para link("Read the Manual.") { Shoes.show_manual and close }, :margin => 10
+ end
+ inscription "Alt-Slash opens the console.", :stroke => "#DFA", :align => "center"
+ end
+
+ animate(10) do |ani|
+ a = Math.sin(ani * 0.02) * 20
+ @waves.clear do
+ background white
+ y = -30
+ 16.times do |i|
+ shape do
+ move_to x = (-300 - (i*(a*0.8))), y
+ c = (a + 14) * 0.01
+ stroke rgb(i * 0.06, c + 0.1, 0.1, 1.0 - (ani * 0.0003))
+ 4.times do
+ curve_to x1 + x, (y1-(i*a)) + y, x2 + x, (y2+(i*a)) + y, x3 + x, y3 + y
+ x += x3
+ end
+ end
+ y += 30
+ end
+ end
+ end
+ end
+ end
+
+ def self.make_pack
+ require 'shoes/pack'
+ Shoes.app(:width => 500, :height => 480, :resizable => true, &PackMake)
+ end
+
+ def self.manual_p(str, path)
+ str.gsub(/\n+\s*/, " ").
+ gsub(/&/, '&amp;').gsub(/>/, '&gt;').gsub(/>/, '&lt;').gsub(/"/, '&quot;').
+ gsub(/`(.+?)`/m, '<code>\1</code>').gsub(/\[\[BR\]\]/i, "<br />\n").
+ gsub(/\^(.+?)\^/m, '\1').
+ gsub(/'''(.+?)'''/m, '<strong>\1</strong>').gsub(/''(.+?)''/m, '<em>\1</em>').
+ gsub(/\[\[(http:\/\/\S+?)\]\]/m, '<a href="\1" target="_new">\1</a>').
+ gsub(/\[\[(http:\/\/\S+?) (.+?)\]\]/m, '<a href="\1" target="_new">\2</a>').
+ gsub(/\[\[(\S+?)\]\]/m) do
+ ms, mn = $1.split(".", 2)
+ if mn
+ '<a href="' + ms + '.html#' + mn + '">' + mn + '</a>'
+ else
+ '<a href="' + ms + '.html">' + ms + '</a>'
+ end
+ end.
+ gsub(/\[\[(\S+?) (.+?)\]\]/m, '<a href="\1.html">\2</a>').
+ gsub(/\!(\{[^}\n]+\})?([^!\n]+\.\w+)\!/) do
+ x = "static/#$2"
+ FileUtils.cp("#{DIR}/#{x}", "#{path}/#{x}") if File.exists? "#{DIR}/#{x}"
+ '<img src="' + x + '" />'
+ end
+ end
+
+ def self.manual_link(sect)
+ end
+
+ TITLES = {:title => :h1, :subtitle => :h2, :tagline => :h3, :caption => :h4}
+
+ def self.manual_as format, *args
+ require 'shoes/search'
+ require 'shoes/help'
+
+ case format
+ when :shoes
+ Shoes.app(:width => 720, :height => 640, &Shoes::Help)
+ else
+ extend Shoes::Manual
+ man = self
+ dir, = args
+ FileUtils.mkdir_p File.join(dir, 'static')
+ FileUtils.cp "#{DIR}/static/shoes-icon.png", "#{dir}/static"
+ %w[manual.css code_highlighter.js code_highlighter_ruby.js].
+ each { |x| FileUtils.cp "#{DIR}/static/#{x}", "#{dir}/static" }
+ html_bits = proc do
+ proc do |sym, text|
+ case sym when :intro
+ div.intro { p { self << man.manual_p(text, dir) } }
+ when :code
+ pre { code.rb text.gsub(/^\s*?\n/, '') }
+ when :colors
+ color_names = (Shoes::COLORS.keys*"\n").split("\n").sort
+ color_names.each do |color|
+ c = Shoes::COLORS[color.intern]
+ f = c.dark? ? "white" : "black"
+ div.color(:style => "background: #{c}; color: #{f}") { h3 color; p c }
+ end
+ when :index
+ tree = man.class_tree
+ shown = []
+ i = 0
+ index_p = proc do |k, subs|
+ unless shown.include? k
+ i += 1
+ p "#{k}", :style => "margin-left: #{20*i}px"
+ subs.uniq.sort.each do |s|
+ index_p[s, tree[s]]
+ end if subs
+ i -= 1
+ shown << k
+ end
+ end
+ tree.sort.each &index_p
+ # index_page
+ when :list
+ ul { text.each { |x| li { self << man.manual_p(x, dir) } } }
+ when :samples
+ folder = File.join DIR, 'samples'
+ h = {}
+ Dir.glob(File.join folder, '*').each do |file|
+ if File.extname(file) == '.rb'
+ key = File.basename(file).split('-')[0]
+ h[key] ? h[key].push(file) : h[key] = [file]
+ end
+ end
+ h.each do |k, v|
+ p "<h4>#{k}</h4>"
+ samples = []
+ v.each do |file|
+ sample = File.basename(file).split('-')[1..-1].join('-')[0..-4]
+ samples << "<a href=\"http://github.com/shoes/shoes/raw/master/manual-snapshots/#{k}-#{sample}.png\">#{sample}</a>"
+ end
+ p samples.join ' '
+ end
+ else
+ send(TITLES[sym] || :p) { self << man.manual_p(text, dir) }
+ end
+ end
+ end
+
+ docs = load_docs(Shoes::Manual::path)
+ sections = docs.map { |x,| x }
+
+ docn = 1
+ docs.each do |title1, opt1|
+ subsect = opt1['sections'].map { |x,| x }
+ menu = sections.map do |x|
+ [x, (subsect if x == title1)]
+ end
+
+ path1 = File.join(dir, title1.gsub(/\W/, ''))
+ make_html("#{path1}.html", title1, menu) do
+ h2 "The Shoes Manual"
+ h1 title1
+ man.wiki_tokens opt1['description'], true, &instance_eval(&html_bits)
+ p.next { text "Next: "
+ a opt1['sections'].first[1]['title'], :href => "#{opt1['sections'].first[0]}.html" }
+ end
+
+ optn = 1
+ opt1['sections'].each do |title2, opt2|
+ path2 = File.join(dir, title2)
+ make_html("#{path2}.html", opt2['title'], menu) do
+ h2 "The Shoes Manual"
+ h1 opt2['title']
+ man.wiki_tokens opt2['description'], true, &instance_eval(&html_bits)
+ opt2['methods'].each do |title3, desc3|
+ sig, val = title3.split(/\s\s+/, 2)
+ aname = sig[/^[^(=]+=?/].gsub(/\s/, '').downcase
+ a :name => aname
+ div.method do
+ a sig, :href => "##{aname}"
+ text " » #{val}" if val
+ end
+ div.sample do
+ man.wiki_tokens desc3, &instance_eval(&html_bits)
+ end
+ end
+ if opt1['sections'][optn]
+ p.next { text "Next: "
+ a opt1['sections'][optn][1]['title'], :href => "#{opt1['sections'][optn][0]}.html" }
+ elsif docs[docn]
+ p.next { text "Next: "
+ a docs[docn][0], :href => "#{docs[docn][0].gsub(/\W/, '')}.html" }
+ end
+ optn += 1
+ end
+ end
+
+ docn += 1
+ end
+ end
+ end
+
+ def self.show_manual
+ manual_as :shoes
+ end
+
+ def self.show_log
+ require 'shoes/log'
+ return if @log_app and Shoes.APPS.include? @log_app
+ @log_app =
+ Shoes.app do
+ extend Shoes::LogWindow
+ setup
+ end
+ end
+
+ def self.mount(path, meth, &blk)
+ @mounts << [path, meth || blk]
+ end
+
+ SHOES_URL_RE = %r!^@([^/]+)(.*)$!
+
+ def self.run(path)
+ uri = URI(path)
+ @mounts.each do |mpath, rout|
+ m, *args = *path.match(/^#{mpath}$/)
+ if m
+ unless rout.is_a? Proc
+ rout = rout[0].instance_method(rout[1])
+ end
+ return [rout, args]
+ end
+ end
+ case uri.path when "/"
+ [nil]
+ when SHOES_URL_RE
+ [proc { eval(URI("http://#$1:53045#$2").read) }]
+ else
+ [NotFound]
+ end
+ end
+
+ def self.args!
+ if RUBY_PLATFORM !~ /darwin/ and ARGV.empty?
+ Shoes.splash
+ end
+ OPTS.parse! ARGV
+ ARGV[0] or true
+ end
+
+ def self.uri(str)
+ if str =~ SHOES_URL_RE
+ URI("http://#$1:53045#$2")
+ else
+ URI(str) rescue nil
+ end
+ end
+
+ def self.visit(path)
+ uri = Shoes.uri(path)
+
+ case uri
+ when URI::HTTP
+ str = uri.read
+ if str !~ /Shoes\.app/
+ Shoes.app do
+ eval(uri.read)
+ end
+ else
+ eval(uri.read)
+ end
+ else
+ path = File.expand_path(path.gsub(/\\/, "/"))
+ if path =~ /\.shy$/
+ @shy = true
+ require 'shoes/shy'
+ base = File.basename(path, ".shy")
+ tmpdir = "%s/shoes-%s.%d" % [Dir.tmpdir, base, $$]
+ shy = Shy.x(path, tmpdir)
+ Dir.chdir(tmpdir)
+ Shoes.debug "Loaded SHY: #{shy.name} #{shy.version} by #{shy.creator}"
+ path = shy.launch
+ else
+ @shy = false
+ Dir.chdir(File.dirname(path))
+ path = File.basename(path)
+ end
+
+ $0.replace path
+
+ code = read_file(path)
+ eval(code, TOPLEVEL_BINDING, path)
+ end
+ rescue SettingUp
+ rescue Object => e
+ error(e)
+ show_log
+ end
+
+ def self.read_file path
+ if RUBY_VERSION =~ /^1\.9/ and !@shy
+ #File.open(path, 'r:utf-8') { |f| f.read }
+ IO.read(path).force_encoding("UTF-8")
+ else
+ File.read(path)
+ end
+ end
+
+ def self.url(path, meth)
+ Shoes.mount(path, [self, meth])
+ end
+
+ module Basic
+ def tween opts, &blk
+ opts = opts.dup
+
+ if opts[:upward]
+ opts[:top] = self.top - opts.delete(:upward)
+ elsif opts[:downward]
+ opts[:top] = self.top + opts.delete(:downward)
+ end
+
+ if opts[:sideways]
+ opts[:left] = self.left + opts.delete(:sideways)
+ end
+
+ @TWEEN.remove if @TWEEN
+ @TWEEN = parent.animate(opts[:speed] || 20) do
+
+ # figure out a coordinate halfway between here and there
+ cont = opts.select do |k, v|
+ if self.respond_to? k
+ n, o = v, self.send(k)
+ if n != o
+ n = o + ((n - o) / 2)
+ n = v if o == n
+ self.send("#{k}=", n)
+ end
+ self.style[k] != v
+ end
+ end
+
+ # if we're there, get rid of the animation
+ if cont.empty?
+ @TWEEN.remove
+ @TWEEN = nil
+ blk.call if blk
+ end
+ end
+ end
+ end
+
+ # complete list of styles
+ BASIC_S = [:left, :top, :right, :bottom, :width, :height, :attach, :hidden,
+ :displace_left, :displace_top, :margin, :margin_left, :margin_top,
+ :margin_right, :margin_bottom]
+ TEXT_S = [:strikecolor, :undercolor, :font, :size, :family, :weight,
+ :rise, :kerning, :emphasis, :strikethrough, :stretch, :underline,
+ :variant]
+ MOUSE_S = [:click, :motion, :release, :hover, :leave]
+ KEY_S = [:keydown, :keypress, :keyup]
+ COLOR_S = [:stroke, :fill]
+
+ {Background => [:angle, :radius, :curve, *BASIC_S],
+ Border => [:angle, :radius, :curve, :strokewidth, *BASIC_S],
+ Canvas => [:scroll, :start, :finish, *(KEY_S|MOUSE_S|BASIC_S)],
+ Check => [:click, :checked, *BASIC_S],
+ Radio => [:click, :checked, :group, *BASIC_S],
+ EditLine => [:change, :secret, :text, *BASIC_S],
+ EditBox => [:change, :text, *BASIC_S],
+ Effect => [:radius, :distance, :inner, *(COLOR_S|BASIC_S)],
+ Image => MOUSE_S|BASIC_S,
+ ListBox => [:change, :items, :choose, *BASIC_S],
+ # Pattern => [:angle, :radius, *BASIC_S],
+ Progress => BASIC_S,
+ Shape => COLOR_S|MOUSE_S|BASIC_S,
+ TextBlock => [:justify, :align, :leading, *(COLOR_S|MOUSE_S|TEXT_S|BASIC_S)],
+ Text => COLOR_S|MOUSE_S|TEXT_S|BASIC_S}.
+ each do |klass, styles|
+ klass.class_eval do
+ include Basic
+ styles.each do |m|
+ case m when *MOUSE_S
+ else
+ define_method(m) { style[m] } unless klass.method_defined? m
+ define_method("#{m}=") { |v| style(m => v) } unless klass.method_defined? "#{m}="
+ end
+ end
+ end
+ end
+
+ class Types::Widget
+ @types = {}
+ def self.inherited subc
+ methc = subc.to_s[/(^|::)(\w+)$/, 2].
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
+ @types[methc] = subc
+ Shoes.class_eval %{
+ def #{methc}(*a, &b)
+ a.unshift Widget.instance_variable_get("@types")[#{methc.dump}]
+ widget(*a, &b)
+ end
+ }
+ end
+ end
+end
+
+def window(*a, &b)
+ Shoes.app(*a, &b)
+end
View
0  lib/shoes/cache.rb → lib/red_shoes/cache.rb
File renamed without changes
View
0  lib/shoes/chipmunk.rb → lib/red_shoes/chipmunk.rb
File renamed without changes
View
0  lib/shoes/data.rb → lib/red_shoes/data.rb
File renamed without changes
View
0  lib/shoes/help.rb → lib/red_shoes/help.rb
File renamed without changes
View
0  lib/shoes/image.rb → lib/red_shoes/image.rb
File renamed without changes
View
0  lib/shoes/inspect.rb → lib/red_shoes/inspect.rb
File renamed without changes
View
0  lib/shoes/log.rb → lib/red_shoes/log.rb
File renamed without changes
View
0  lib/shoes/minitar.rb → lib/red_shoes/minitar.rb
File renamed without changes
View
0  lib/shoes/override.rb → lib/red_shoes/override.rb
File renamed without changes
View
0  lib/shoes/pack.rb → lib/red_shoes/pack.rb
File renamed without changes
View
0  lib/shoes/search.rb → lib/red_shoes/search.rb
File renamed without changes
View
0  lib/shoes/setup.rb → lib/red_shoes/setup.rb
File renamed without changes
View
0  lib/shoes/shy.rb → lib/red_shoes/shy.rb
File renamed without changes
View
0  lib/shoes/shybuilder.rb → lib/red_shoes/shybuilder.rb
File renamed without changes
View
0  lib/shoes/version.rb → lib/red_shoes/version.rb
File renamed without changes
View
571 lib/shoes.rb
@@ -1,554 +1,41 @@
-# -*- encoding: utf-8 -*-
-#
-# lib/shoes.rb
-# The Shoes base app, both a demonstration and the learning tool for
-# using Shoes.
-#
-ARGV.delete_if { |x| x =~ /-psn_/ }
+require 'java'
-class Encoding
- %w[UTF_7 UTF_16BE UTF_16LE UTF_32BE UTF_32LE].each do |enc|
- eval "class #{enc};end" unless const_defined? enc.to_sym
- end
-end
-
-require 'open-uri'
-require 'optparse'
-require 'resolv-replace' if RUBY_PLATFORM =~ /win/
-require_relative 'shoes/inspect'
-require_relative 'shoes/cache'
-if Object.const_defined? :Shoes
- require_relative 'shoes/image'
-end
-require_relative 'shoes/shybuilder'
-
-def Shoes.hook; end
-
-class Encoding
- %w[ASCII_8BIT UTF_16BE UTF_16LE UTF_32BE UTF_32LE US_ASCII].each do |ec|
- eval "#{ec} = '#{ec.sub '_', '-'}'"
- end unless RUBY_PLATFORM =~ /linux/ or RUBY_PLATFORM =~ /darwin/
-end
-
-class Range
- def rand
- conv = (Integer === self.end && Integer === self.begin ? :to_i : :to_f)
- ((Kernel.rand * (self.end - self.begin)) + self.begin).send(conv)
- end
-end
-
-unless Time.respond_to? :today
- def Time.today
- t = Time.now
- t - (t.to_i % 86400)
- end
-end
-
-class Shoes
- RELEASES = %w[Curious Raisins Policeman]
-
- NotFound = proc do
- para "404 NOT FOUND, GUYS!"
- end
-
- class << self; attr_accessor :locale, :language end
- @locale = ENV["SHOES_LANG"] || ENV["LC_MESSAGES"] || ENV["LC_ALL"] || ENV["LANG"] || "C"
- @language = @locale[/^(\w{2})_/, 1] || "en"
+require 'swt.jar'
- @mounts = []
+require 'rubygems'
+require 'facets/hash'
- OPTS = OptionParser.new do |opts|
- opts.banner = "Usage: shoes [options] (app.rb or app.shy)"
-
- opts.on("-m", "--manual",
- "Open the built-in manual.") do
- show_manual
- end
+require 'lib/log4j/log4j-1.2.16.jar'
+require 'log4jruby'
+require 'log4jruby/logger_for_class'
+logger = Log4jruby::Logger.get('test', :tracing => true, :level => :debug )
+logger.debug("Shooes!")
- opts.on("-p", "--package",
- "Package a Shoes app for Windows, OS X and Linux.") do |s|
- make_pack
- end
- opts.on("-g", "--gem",
- "Passes commands to RubyGems.") do
- require 'shoes/setup'
- require 'rubygems/gem_runner'
- Gem::GemRunner.new.run(ARGV)
- raise SystemExit, ""
- end
+require 'shoes/swt_constants'
- opts.on("--manual-html DIRECTORY", "Saves the manual to a directory as HTML.") do |dir|
- manual_as :html, dir
- raise SystemExit, "HTML manual in: #{dir}"
- end
+require 'shoes/app'
+require 'shoes/elements'
+require 'shoes/window'
+require 'shoes/flow'
+require 'shoes/button'
- opts.on("--install MODE SRC DEST", "Installs a file.") do |mode|
- src, dest = ARGV
- FileUtils.install src, dest, :mode => mode.to_i(8), :preserve => true
- raise SystemExit, ""
- end
+#require 'shoes/elements/element'
+#require 'shoes/elements/button'
+#require 'shoes/elements/stack'
+#require 'shoes/elements/flow'
+#require 'shoes/elements/edit_line'
+#require 'shoes/elements/edit_box'
+#require 'shoes/elements/check'
+#require 'shoes/elements/image'
- opts.on("--nolayered", "No WS_EX_LAYERED style option.") do
- $NOLAYERED = 1
- Shoes.args!
- end
-
- opts.on_tail("-v", "--version", "Display the version info.") do
- raise SystemExit, File.read("#{DIR}/VERSION.txt").strip
- end
+module Shoes
+ include SwtConstants
+ include Log4jruby::LoggerForClass
- opts.on_tail("-h", "--help", "Show this message") do
- raise SystemExit, opts.to_s
- end
+ def self.app(opts={}, &blk)
+ Shoes::App.new(opts, &blk)
+ logger.debug "Exiting Shoes.app"
end
- class SettingUp < StandardError; end
-
- @setups = {}
-
- def self.setup &blk
- require 'shoes/setup'
- line = caller[0]
- return if @setups[line]
- script = line[/^(.+?):/, 1]
- set = Shoes::Setup.new(script, &blk)
- @setups[line] = true
- unless set.no_steps?
- raise SettingUp
- end
- end
-
- def self.show_selector
- fname = ask_open_file
- Shoes.visit(fname) if fname
- end
-
- def self.package_app
- fname = ask_open_file
- return false unless fname
- start_shy_builder fname
- end
-
- def self.splash
- font "#{DIR}/fonts/Lacuna.ttf"
- Shoes.app :width => 400, :height => 300, :resizable => false do
- style(Para, :align => "center", :weight => "bold", :font => "Lacuna Regular", :size => 13)
- style(Link, :stroke => yellow, :underline => nil)
- style(LinkHover, :stroke => yellow, :fill => nil)
-
- x1 = 77; y1 = 122
- x2 = 148; y2 = -122
- x3 = 245; y3 = 0
-
- nofill
- strokewidth 40.0
-
- @waves = stack :top => 0, :left => 0
-
- require 'shoes/search'
- require 'shoes/help'
-
- stack :margin => 18 do
- para "Welcome to", :stroke => "#DFA", :margin => 0
- para "SHOES", :size => 48, :stroke => "#DFA", :margin_top => 0
- stack do
- background black(0.2), :curve => 8
- para link("Open an App.") { Shoes.show_selector and close }, :margin => 10, :margin_bottom => 4
- #para link("Package an App.") { Shoes.package_app and close }, :margin => 10, :margin_bottom => 4
- para link("Package an App.") { Shoes.make_pack and close }, :margin => 10, :margin_bottom => 4
- para link("Read the Manual.") { Shoes.show_manual and close }, :margin => 10
- end
- inscription "Alt-Slash opens the console.", :stroke => "#DFA", :align => "center"
- end
-
- animate(10) do |ani|
- a = Math.sin(ani * 0.02) * 20
- @waves.clear do
- background white
- y = -30
- 16.times do |i|
- shape do
- move_to x = (-300 - (i*(a*0.8))), y
- c = (a + 14) * 0.01
- stroke rgb(i * 0.06, c + 0.1, 0.1, 1.0 - (ani * 0.0003))
- 4.times do
- curve_to x1 + x, (y1-(i*a)) + y, x2 + x, (y2+(i*a)) + y, x3 + x, y3 + y
- x += x3
- end
- end
- y += 30
- end
- end
- end
- end
- end
-
- def self.make_pack
- require 'shoes/pack'
- Shoes.app(:width => 500, :height => 480, :resizable => true, &PackMake)
- end
-
- def self.manual_p(str, path)
- str.gsub(/\n+\s*/, " ").
- gsub(/&/, '&amp;').gsub(/>/, '&gt;').gsub(/>/, '&lt;').gsub(/"/, '&quot;').
- gsub(/`(.+?)`/m, '<code>\1</code>').gsub(/\[\[BR\]\]/i, "<br />\n").
- gsub(/\^(.+?)\^/m, '\1').
- gsub(/'''(.+?)'''/m, '<strong>\1</strong>').gsub(/''(.+?)''/m, '<em>\1</em>').
- gsub(/\[\[(http:\/\/\S+?)\]\]/m, '<a href="\1" target="_new">\1</a>').
- gsub(/\[\[(http:\/\/\S+?) (.+?)\]\]/m, '<a href="\1" target="_new">\2</a>').
- gsub(/\[\[(\S+?)\]\]/m) do
- ms, mn = $1.split(".", 2)
- if mn
- '<a href="' + ms + '.html#' + mn + '">' + mn + '</a>'
- else
- '<a href="' + ms + '.html">' + ms + '</a>'
- end
- end.
- gsub(/\[\[(\S+?) (.+?)\]\]/m, '<a href="\1.html">\2</a>').
- gsub(/\!(\{[^}\n]+\})?([^!\n]+\.\w+)\!/) do
- x = "static/#$2"
- FileUtils.cp("#{DIR}/#{x}", "#{path}/#{x}") if File.exists? "#{DIR}/#{x}"
- '<img src="' + x + '" />'
- end
- end
-
- def self.manual_link(sect)
- end
-
- TITLES = {:title => :h1, :subtitle => :h2, :tagline => :h3, :caption => :h4}
-
- def self.manual_as format, *args
- require 'shoes/search'
- require 'shoes/help'
-
- case format
- when :shoes
- Shoes.app(:width => 720, :height => 640, &Shoes::Help)
- else
- extend Shoes::Manual
- man = self
- dir, = args
- FileUtils.mkdir_p File.join(dir, 'static')
- FileUtils.cp "#{DIR}/static/shoes-icon.png", "#{dir}/static"
- %w[manual.css code_highlighter.js code_highlighter_ruby.js].
- each { |x| FileUtils.cp "#{DIR}/static/#{x}", "#{dir}/static" }
- html_bits = proc do
- proc do |sym, text|
- case sym when :intro
- div.intro { p { self << man.manual_p(text, dir) } }
- when :code
- pre { code.rb text.gsub(/^\s*?\n/, '') }
- when :colors
- color_names = (Shoes::COLORS.keys*"\n").split("\n").sort
- color_names.each do |color|
- c = Shoes::COLORS[color.intern]
- f = c.dark? ? "white" : "black"
- div.color(:style => "background: #{c}; color: #{f}") { h3 color; p c }
- end
- when :index
- tree = man.class_tree
- shown = []
- i = 0
- index_p = proc do |k, subs|
- unless shown.include? k
- i += 1
- p "#{k}", :style => "margin-left: #{20*i}px"
- subs.uniq.sort.each do |s|
- index_p[s, tree[s]]
- end if subs
- i -= 1
- shown << k
- end
- end
- tree.sort.each &index_p
- # index_page
- when :list
- ul { text.each { |x| li { self << man.manual_p(x, dir) } } }
- when :samples
- folder = File.join DIR, 'samples'
- h = {}
- Dir.glob(File.join folder, '*').each do |file|
- if File.extname(file) == '.rb'
- key = File.basename(file).split('-')[0]
- h[key] ? h[key].push(file) : h[key] = [file]
- end
- end
- h.each do |k, v|
- p "<h4>#{k}</h4>"
- samples = []
- v.each do |file|
- sample = File.basename(file).split('-')[1..-1].join('-')[0..-4]
- samples << "<a href=\"http://github.com/shoes/shoes/raw/master/manual-snapshots/#{k}-#{sample}.png\">#{sample}</a>"
- end
- p samples.join ' '
- end
- else
- send(TITLES[sym] || :p) { self << man.manual_p(text, dir) }
- end
- end
- end
-
- docs = load_docs(Shoes::Manual::path)
- sections = docs.map { |x,| x }
-
- docn = 1
- docs.each do |title1, opt1|
- subsect = opt1['sections'].map { |x,| x }
- menu = sections.map do |x|
- [x, (subsect if x == title1)]
- end
-
- path1 = File.join(dir, title1.gsub(/\W/, ''))
- make_html("#{path1}.html", title1, menu) do
- h2 "The Shoes Manual"
- h1 title1
- man.wiki_tokens opt1['description'], true, &instance_eval(&html_bits)
- p.next { text "Next: "
- a opt1['sections'].first[1]['title'], :href => "#{opt1['sections'].first[0]}.html" }
- end
-
- optn = 1
- opt1['sections'].each do |title2, opt2|
- path2 = File.join(dir, title2)
- make_html("#{path2}.html", opt2['title'], menu) do
- h2 "The Shoes Manual"
- h1 opt2['title']
- man.wiki_tokens opt2['description'], true, &instance_eval(&html_bits)
- opt2['methods'].each do |title3, desc3|
- sig, val = title3.split(/\s\s+/, 2)
- aname = sig[/^[^(=]+=?/].gsub(/\s/, '').downcase
- a :name => aname
- div.method do
- a sig, :href => "##{aname}"
- text " » #{val}" if val
- end
- div.sample do
- man.wiki_tokens desc3, &instance_eval(&html_bits)
- end
- end
- if opt1['sections'][optn]
- p.next { text "Next: "
- a opt1['sections'][optn][1]['title'], :href => "#{opt1['sections'][optn][0]}.html" }
- elsif docs[docn]
- p.next { text "Next: "
- a docs[docn][0], :href => "#{docs[docn][0].gsub(/\W/, '')}.html" }
- end
- optn += 1
- end
- end
-
- docn += 1
- end
- end
- end
-
- def self.show_manual
- manual_as :shoes
- end
-
- def self.show_log
- require 'shoes/log'
- return if @log_app and Shoes.APPS.include? @log_app
- @log_app =
- Shoes.app do
- extend Shoes::LogWindow
- setup
- end
- end
-
- def self.mount(path, meth, &blk)
- @mounts << [path, meth || blk]
- end
-
- SHOES_URL_RE = %r!^@([^/]+)(.*)$!
-
- def self.run(path)
- uri = URI(path)
- @mounts.each do |mpath, rout|
- m, *args = *path.match(/^#{mpath}$/)
- if m
- unless rout.is_a? Proc
- rout = rout[0].instance_method(rout[1])
- end
- return [rout, args]
- end
- end
- case uri.path when "/"
- [nil]
- when SHOES_URL_RE
- [proc { eval(URI("http://#$1:53045#$2").read) }]
- else
- [NotFound]
- end
- end
-
- def self.args!
- if RUBY_PLATFORM !~ /darwin/ and ARGV.empty?
- Shoes.splash
- end
- OPTS.parse! ARGV
- ARGV[0] or true
- end
-
- def self.uri(str)
- if str =~ SHOES_URL_RE
- URI("http://#$1:53045#$2")
- else
- URI(str) rescue nil
- end
- end
-
- def self.visit(path)
- uri = Shoes.uri(path)
-
- case uri
- when URI::HTTP
- str = uri.read
- if str !~ /Shoes\.app/
- Shoes.app do
- eval(uri.read)
- end
- else
- eval(uri.read)
- end
- else
- path = File.expand_path(path.gsub(/\\/, "/"))
- if path =~ /\.shy$/
- @shy = true
- require 'shoes/shy'
- base = File.basename(path, ".shy")
- tmpdir = "%s/shoes-%s.%d" % [Dir.tmpdir, base, $$]
- shy = Shy.x(path, tmpdir)
- Dir.chdir(tmpdir)
- Shoes.debug "Loaded SHY: #{shy.name} #{shy.version} by #{shy.creator}"
- path = shy.launch
- else
- @shy = false
- Dir.chdir(File.dirname(path))
- path = File.basename(path)
- end
-
- $0.replace path
-
- code = read_file(path)
- eval(code, TOPLEVEL_BINDING, path)
- end
- rescue SettingUp
- rescue Object => e
- error(e)
- show_log
- end
-
- def self.read_file path
- if RUBY_VERSION =~ /^1\.9/ and !@shy
- #File.open(path, 'r:utf-8') { |f| f.read }
- IO.read(path).force_encoding("UTF-8")
- else
- File.read(path)
- end
- end
-
- def self.url(path, meth)
- Shoes.mount(path, [self, meth])
- end
-
- module Basic
- def tween opts, &blk
- opts = opts.dup
-
- if opts[:upward]
- opts[:top] = self.top - opts.delete(:upward)
- elsif opts[:downward]
- opts[:top] = self.top + opts.delete(:downward)
- end
-
- if opts[:sideways]
- opts[:left] = self.left + opts.delete(:sideways)
- end
-
- @TWEEN.remove if @TWEEN
- @TWEEN = parent.animate(opts[:speed] || 20) do
-
- # figure out a coordinate halfway between here and there
- cont = opts.select do |k, v|
- if self.respond_to? k
- n, o = v, self.send(k)
- if n != o
- n = o + ((n - o) / 2)
- n = v if o == n
- self.send("#{k}=", n)
- end
- self.style[k] != v
- end
- end
-
- # if we're there, get rid of the animation
- if cont.empty?
- @TWEEN.remove
- @TWEEN = nil
- blk.call if blk
- end
- end
- end
- end
-
- # complete list of styles
- BASIC_S = [:left, :top, :right, :bottom, :width, :height, :attach, :hidden,
- :displace_left, :displace_top, :margin, :margin_left, :margin_top,
- :margin_right, :margin_bottom]
- TEXT_S = [:strikecolor, :undercolor, :font, :size, :family, :weight,
- :rise, :kerning, :emphasis, :strikethrough, :stretch, :underline,
- :variant]
- MOUSE_S = [:click, :motion, :release, :hover, :leave]
- KEY_S = [:keydown, :keypress, :keyup]
- COLOR_S = [:stroke, :fill]
-
- {Background => [:angle, :radius, :curve, *BASIC_S],
- Border => [:angle, :radius, :curve, :strokewidth, *BASIC_S],
- Canvas => [:scroll, :start, :finish, *(KEY_S|MOUSE_S|BASIC_S)],
- Check => [:click, :checked, *BASIC_S],
- Radio => [:click, :checked, :group, *BASIC_S],
- EditLine => [:change, :secret, :text, *BASIC_S],
- EditBox => [:change, :text, *BASIC_S],
- Effect => [:radius, :distance, :inner, *(COLOR_S|BASIC_S)],
- Image => MOUSE_S|BASIC_S,
- ListBox => [:change, :items, :choose, *BASIC_S],
- # Pattern => [:angle, :radius, *BASIC_S],
- Progress => BASIC_S,
- Shape => COLOR_S|MOUSE_S|BASIC_S,
- TextBlock => [:justify, :align, :leading, *(COLOR_S|MOUSE_S|TEXT_S|BASIC_S)],
- Text => COLOR_S|MOUSE_S|TEXT_S|BASIC_S}.
- each do |klass, styles|
- klass.class_eval do
- include Basic
- styles.each do |m|
- case m when *MOUSE_S
- else
- define_method(m) { style[m] } unless klass.method_defined? m
- define_method("#{m}=") { |v| style(m => v) } unless klass.method_defined? "#{m}="
- end
- end
- end
- end
-
- class Types::Widget
- @types = {}
- def self.inherited subc
- methc = subc.to_s[/(^|::)(\w+)$/, 2].
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
- gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
- @types[methc] = subc
- Shoes.class_eval %{
- def #{methc}(*a, &b)
- a.unshift Widget.instance_variable_get("@types")[#{methc.dump}]
- widget(*a, &b)
- end
- }
- end
- end
-end
-
-def window(*a, &b)
- Shoes.app(*a, &b)
end
View
41 lib/shoes/app.rb
@@ -0,0 +1,41 @@
+module Shoes
+ class App
+ include SwtConstants
+ include Log4jruby::LoggerForClass
+
+ attr_accessor :elements, :frame
+ attr_accessor :main_shell
+
+ def initialize(opts={}, &blk)
+ @elements = {}
+ #@frame = javax.swing.JFrame.new()
+
+
+ $main_display = SwtDisplay.getDefault
+
+ window_opts = opts.merge(:on_close => main_window_on_close, :elements => @elements)
+ @main_window = Window.new(window_opts) do
+ flow do
+ instance_eval &blk if block_given?
+ end
+ end
+
+ while (!$main_display.isDisposed) do
+ $main_display.sleep unless $main_display.readAndDispatch
+ end
+
+ $main_display.dispose unless $main_display.isDisposed
+
+ logger.debug "$main_display disposed... exiting Shoes::App.new"
+ end
+
+ private
+ def main_window_on_close
+ lambda {
+ logger.debug "main_window on_close block begin... disposing $main_display"
+ $main_display.dispose
+ logger.debug "$main_display disposed"
+ }
+ end
+ end
+end
View
15 lib/shoes/button.rb
@@ -0,0 +1,15 @@
+require 'shoes/element'
+
+module Shoes
+ class Button < Element
+
+ def initialize(shell, text, opts = {}, &blk)
+ @swt_button = SwtButton.new(shell, Swt::PUSH)
+ @swt_button.setText(text)
+ @swt_button.setBounds(10, 10, 150, 30)
+ @swt_button.addSelectionListener(&blk) if block_given?
+ end
+
+ # To change this template use File | Settings | File Templates.
+ end
+end
View
13 lib/shoes/composite.rb
@@ -0,0 +1,13 @@
+require 'shoes/composites'
+
+module Shoes
+ class Composite
+ include SwtConstants
+ include Log4jruby::LoggerForClass
+ include Elements
+ include Composites
+
+ attr_reader :composite
+
+ end
+end
View
13 lib/shoes/composites.rb
@@ -0,0 +1,13 @@
+module Shoes
+ module Composites
+ #def stack(opts={}, &blk)
+ # tstack = Stack.new(opts)
+ # layout(tstack, &blk)
+ #end
+
+ def flow &blk
+ swt_flow = Shoes::Flow.new @composite, &blk
+ end
+
+ end
+end
View
1  lib/shoes/config_logger.rb
@@ -0,0 +1 @@
+
View
6 lib/shoes/element.rb
@@ -0,0 +1,6 @@
+module Shoes
+ class Element
+ include SwtConstants
+ include Log4jruby::LoggerForClass
+ end
+end
View
46 lib/shoes/elements.rb
@@ -0,0 +1,46 @@
+module Shoes
+ module Elements
+
+ def button(text, opts={}, &blk)
+ button = Shoes::Button.new(@composite, text, opts, &blk)
+ #@elements[button.to_s] = button
+ #button
+ end
+
+ #
+ #def image(path, opts={})
+ # image = Image.new(path, @current_panel, opts)
+ # @elements[image.identifier] = image
+ # image
+ #end
+ #
+ #def edit_line(opts={})
+ # eline = Edit_line.new(@current_panel, opts)
+ # @elements[eline.identifier] = eline
+ # eline
+ #end
+ #
+ #def text_box(opts={})
+ # tbox = Text_box.new(@current_panel, opts)
+ # @elements[tbox.identifier] = tbox
+ # tbox
+ #end
+ #
+ #def check(opts={}, &blk)
+ # cbox = Check.new(@current_panel, opts)
+ # @elements[cbox.identifier] = cbox
+ # cbox
+ #end
+ #
+
+ def layout(layer, &blk)
+ parent = @current_panel
+ @current_panel = layer.panel
+ instance_eval &blk
+ parent.add(@current_panel)
+ @current_panel = parent
+ end
+
+
+ end
+end
View
0  lib/brown_shoes/elements/check.rb → lib/shoes/elements/check.rb
File renamed without changes
View
0  lib/brown_shoes/elements/edit_box.rb → lib/shoes/elements/edit_box.rb
File renamed without changes
View
0  lib/brown_shoes/elements/edit_line.rb → lib/shoes/elements/edit_line.rb
File renamed without changes
View
0  lib/brown_shoes/elements/element.rb → lib/shoes/elements/element.rb
File renamed without changes
View
0  lib/brown_shoes/elements/flow.rb → lib/shoes/elements/flow.rb
File renamed without changes
View
0  lib/brown_shoes/elements/image.rb → lib/shoes/elements/image.rb
File renamed without changes
View
20 lib/shoes/elements/stack.rb
@@ -0,0 +1,20 @@
+module Shoes
+ class Stack < Element
+ java_import "javax.swing.JPanel"
+ java_import "javax.swing.BoxLayout"
+ java_import "java.awt.Dimension"
+
+ attr_accessor :panel
+
+ def initialize(opts={})
+ super(opts)
+ @panel = JPanel.new()
+ layout = BoxLayout.new(@panel, BoxLayout::PAGE_AXIS)
+ @panel.set_layout(layout)
+ if (opts[:width] && opts[:height])
+ @panel.set_preferred_size(java.awt.Dimension.new(opts[:width], opts[:height]))
+ end
+ end
+
+ end
+end
View
18 lib/shoes/flow.rb
@@ -0,0 +1,18 @@
+require 'shoes/composite'
+
+module Shoes
+ class Flow < Composite
+
+ def initialize composite_parent, &blk
+ @composite = SwtComposite.new(composite_parent, Swt::NONE)
+ fill_layout = SwtFillLayout.new
+ fill_layout.type = Swt::VERTICAL
+ @composite.setLayout(fill_layout)
+
+ instance_eval &blk if block_given?
+
+ @composite.pack
+ end
+
+ end
+end
View
8 lib/shoes/stack.rb
@@ -0,0 +1,8 @@
+module Shoes
+ class Stack
+ include SwtConstants
+
+ def initialize
+ # To change this template use File | Settings | File Templates.
+ end
+end
View
11 lib/shoes/swt_constants.rb
@@ -0,0 +1,11 @@
+module SwtConstants
+ Swt = org.eclipse.swt.SWT
+ SwtShell = org.eclipse.swt.widgets.Shell
+ SwtDisplay = org.eclipse.swt.widgets.Display
+
+ SwtComposite = org.eclipse.swt.widgets.Composite
+ SwtFillLayout = org.eclipse.swt.layout.FillLayout
+
+ SwtButton = org.eclipse.swt.widgets.Button
+
+end
View
34 lib/shoes/window.rb
@@ -0,0 +1,34 @@
+require 'shoes/composite'
+
+module Shoes
+ class Window < Composite
+
+ DEFAULT_WIDTH = 800
+ DEFAULT_HEIGHT = 600
+ DEFAULT_TITLE = "Shooes!"
+
+
+ def initialize(opts = {}, &blk)
+ opts.stringify_keys!
+ @elements = opts['elements']
+
+ @composite = SwtShell.new($display, Swt::CLOSE)
+
+ width, height = opts['width'] || DEFAULT_WIDTH, opts['height'] || DEFAULT_HEIGHT
+
+ @composite.setSize(width, height)
+ @composite.setText(opts['title'] || DEFAULT_TITLE)
+
+ if opts['on_close']
+ logger.debug "Shell #{@composite.inspect} adding block #{blk.inspect}"
+ @composite.addListener(Swt::Close, opts['on_close'])
+ end
+
+ instance_eval &blk
+ @composite.pack
+
+ @composite.open
+ end
+
+ end
+end
View
BIN  lib/swt.jar
Binary file not shown
View
6 log4j.properties
@@ -0,0 +1,6 @@
+log4j.appender.Ruby=org.apache.log4j.ConsoleAppender
+log4j.appender.Ruby.layout=org.apache.log4j.PatternLayout
+log4j.appender.Ruby.layout.ConversionPattern=%5p %C (%M) - %m%n
+
+log4j.logger.jruby=debug,Ruby
+log4j.logger.jruby.MyClass=debug
View
2  req/hpricot/lib/hpricot.rb
@@ -7,7 +7,7 @@
# * hpricot/tag.rb: sets up objects for the various types of elements in an HTML document.
# * hpricot/modules.rb: categorizes the various elements using mixins.
# * hpricot/traverse.rb: methods for searching documents.
-# * hpricot/elements.rb: methods for dealing with a group of elements as an Hpricot::Elements list.
+# * hpricot/element.rb: methods for dealing with a group of elements as an Hpricot::Elements list.
# * hpricot/inspect.rb: methods for displaying documents in a readable form.
# If available, Nikolai's UTF-8 library will ease use of utf-8 documents.
View
19 rspec
@@ -0,0 +1,19 @@
+#!/usr/bin/env jruby -J-XstartOnFirstThread
+#
+# This file was generated by RubyGems.
+#
+# The application 'rspec-core' is installed as part of a gem, and
+# this file is here to facilitate running it.
+#
+
+require 'rubygems'
+
+version = ">= 0"
+
+if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
+ version = $1
+ ARGV.shift
+end
+
+gem 'rspec-core', version
+load Gem.bin_path('rspec-core', 'rspec', version)
View
10 shooes
@@ -0,0 +1,10 @@
+#!/usr/bin/env jruby -J-XstartOnFirstThread
+require 'rubygems'
+
+$:<< "lib"
+
+require 'shoes'
+
+require ARGV[0]
+
+exit 0
View
15 shooesd
@@ -0,0 +1,15 @@
+#!/usr/bin/env jruby -J-XstartOnFirstThread --debug
+require 'rubygems'
+require 'ruby-debug'
+
+$:<< "lib"
+
+ENV['log_level'] = 'debug'
+
+require 'shoes'
+
+require ARGV[0]
+
+puts "Exiting ./shooesd. Have a good day!"
+
+exit 0
View
5 spec/brown_shoes_spec.rb
@@ -1,5 +0,0 @@
-require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
-
-describe "Brown Shoes" do
-
-end
View
32 spec/shoes/app_spec.rb
@@ -0,0 +1,32 @@
+require "rspec"
+require 'shoes'
+require 'shoes/app'
+require 'shoes/swt_constants'
+
+include SwtConstants
+
+describe Shoes::App do
+
+ it "eval a block" do
+
+ # mocking for SWT part of $main_display (Shoes::App)
+ mock_display = mock(:display, :isDisposed => true, :dispose => true)
+ SwtDisplay.stub(:getDefault) { mock_display }
+ # mocking for SWT part of Shoes::Window
+ mock_shell = mock(:shell, :setSize => true, :setText => true, :addListener => true, :pack => true, :open => true)
+ SwtShell.stub(:new) { mock_shell }
+
+ # mocking for SWT part of Shoes::Flow
+ mock_composite = mock(:composite, :setLayout => true, :pack => true)
+ SwtComposite.stub(:new) { mock_composite }
+ mock_layout = mock(:layout, :type= => true)
+ SwtFillLayout.stub(:new) { mock_layout }
+
+
+ outer = 0
+ Shoes::App.new do
+ outer = 1
+ end
+ outer.should == 1
+ end
+end
View
0  spec/brown_shoes/check_spec.rb → spec/shoes/check_spec.rb
File renamed without changes
View
0  spec/brown_shoes/element_methods_spec.rb → spec/shoes/element_methods_spec.rb
File renamed without changes
View
0  spec/brown_shoes/elementary_button_spec.rb → spec/shoes/elementary_button_spec.rb
File renamed without changes
View
0  spec/brown_shoes/image_spec.rb → spec/shoes/image_spec.rb
File renamed without changes
View
0  spec/brown_shoes/images/shoe.jpg → spec/shoes/images/shoe.jpg
File renamed without changes
View
25 spec/shoes/window_spec.rb
@@ -0,0 +1,25 @@
+require "spec_helper"
+
+describe "Shoes Window" do
+ before do
+ SwtShell = org.eclipse.swt.widgets.Shell
+ $main_display = mock(:display, :shells => [], :dispose => true)
+ end
+
+ describe "constructor" do
+ it "should create a Swt Shell" do
+
+ mock_shell = mock(:shell, :setSize => true, :setText => true, :open => true)
+ SwtShell.should_receive(:new).and_return mock_shell
+ Shoes::Window.new
+ end
+ it "should pass window args to shell" do
+ mock_shell = mock(:shell, :open => true)
+ SwtShell.should_receive(:new).and_return mock_shell
+ mock_shell.should_receive(:setSize).with(1,2)
+ mock_shell.should_receive(:setText).with("Spec Window")
+ Shoes::Window.new :height => 1, :width => 2, :text => "Spec Window"
+
+ end
+ end
+end
View
29 spec/shoes_spec.rb
@@ -0,0 +1,29 @@
+require 'spec_helper'
+
+describe "Shoes" do
+ let(:mock_window) { mock(:window) }
+ let(:mock_display) { mock(:display, :dispose => true) }
+ before do
+ SwtDisplay.stub!(:new) { mock_display }
+ mock_display.stub!(:shells) { [] }
+ end
+
+ describe "as a simple App" do
+ it "should have a window" do
+ Shoes::Window.should_receive(:new).and_return(mock_window)
+
+ Shoes.app {}
+ end
+ it "should pass opts to the main window" do
+ Shoes::Window.should_receive(:new).
+ with(:title => "Spec Title",
+ :width => 200, :height => 200,
+ :resizable => false).
+ and_return(mock_window)
+
+ Shoes.app(:title => "Spec Title",
+ :width => 200, :height => 200,
+ :resizable => false) {}
+ end
+ end
+end
View
13 spec/spec_helper.rb
@@ -1,9 +1,6 @@
-$LOAD_PATH.unshift(File.dirname(__FILE__))
-$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
-require 'brown_shoes'
-require 'spec'
-require 'spec/autorun'
-Spec::Runner.configure do |config|
-
-end
+$:<< '../lib'
+require 'java'
+require 'swt.jar'
+
+require 'shoes'
View
74 swt_info/ex1.rb
@@ -0,0 +1,74 @@
+#
+#require 'java'
+#require 'swt/swt_wrapper'
+#
+#class ButtonExample
+#
+# def initialize
+# # A Display is the connection between SWT and the native GUI. (jruby-swt-cookbook/apidocs/org/eclipse/swt/widgets/Display.html)
+# display = Swt::Widgets::Display.get_current
+#