diff --git a/brown_shoooes b/brown_shoooes
deleted file mode 100755
index 7340917a..00000000
--- a/brown_shoooes
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env jruby
-require 'rubygems'
-
-$:<< "lib"
-
-require 'brown_shoes'
-
-require ARGV[0]
-
diff --git a/brown_shoooesd b/brown_shoooesd
deleted file mode 100755
index 65ce9b0d..00000000
--- a/brown_shoooesd
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env jruby --debug
-require 'rubygems'
-require 'ruby-debug'
-
-$:<< "lib"
-
-ENV['log_level'] = 'debug'
-
-require 'brown_shoes'
-
-require ARGV[0]
-
-puts "Exiting ./shooesd. Have a good day!"
-
diff --git a/lib/brown_shoes.rb b/lib/brown_shoes.rb
deleted file mode 100644
index ee5df110..00000000
--- a/lib/brown_shoes.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require 'java'
-
-require 'rubygems'
-
-require 'brown_shoes/app'
-require 'brown_shoes/elements/native'
-require 'brown_shoes/elements/layout'
-require 'brown_shoes/elements/button'
-require 'brown_shoes/elements/stack'
-require 'brown_shoes/elements/flow'
-require 'brown_shoes/elements/edit_line'
-require 'brown_shoes/elements/edit_box'
-require 'brown_shoes/elements/check'
-require 'brown_shoes/elements/image'
-
-module Shoes
-
-def self.app(opts={}, &blk)
- Shoes::App.new(opts, &blk)
-end
-
-end
diff --git a/lib/brown_shoes/app.rb b/lib/brown_shoes/app.rb
deleted file mode 100644
index 30f827dd..00000000
--- a/lib/brown_shoes/app.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-module Shoes
-class App
- import javax.swing.JPanel
- import javax.swing.JFrame
-
- attr_accessor :elements,:frame
-
- def initialize(opts={}, &blk)
- @elements = {}
- @frame = JFrame.new()
-
- @global_container = JPanel.new()
- @current_panel = @global_container
-
- flow(opts, &blk)
-
- @frame.add(@global_container)
- @frame.setDefaultCloseOperation(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(@global_container, opts, &blk)
- #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
\ No newline at end of file
diff --git a/lib/brown_shoes/elements/button.rb b/lib/brown_shoes/elements/button.rb
deleted file mode 100644
index 0541bcad..00000000
--- a/lib/brown_shoes/elements/button.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-module Shoes
- class Button < Native
-
- attr_accessor :native_widget
-
- def initialize(parent, text = 'Button', opts={}, &blk)
- super(opts)
- @native_widget = javax.swing.JButton.new(text)
- @native_widget.add_action_listener(&blk) unless blk.nil?
- parent.add(@native_widget)
- return self
- end
-
- end
-end
\ No newline at end of file
diff --git a/lib/brown_shoes/elements/flow.rb b/lib/brown_shoes/elements/flow.rb
deleted file mode 100644
index 0eda6e97..00000000
--- a/lib/brown_shoes/elements/flow.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-module Shoes
-class Flow < Layout
- import javax.swing.JPanel
- import javax.swing.BoxLayout
- import java.awt.Dimension
- import javax.swing.border.EmptyBorder
-
- attr_accessor :parent_container, :container
-
- def initialize(parent_container, opts={}, &blk)
- @parent_container = parent_container
- @container = JPanel.new()
- layout = BoxLayout.new(@container, BoxLayout::LINE_AXIS)
- @container.set_layout(layout)
-
- if(opts[:height] && opts[:width])
- @container.set_preferred_size(java.awt.Dimension.new(opts[:width], opts[:height]))
- end
-
- if margin = opts[:margin]
- @container.border = EmptyBorder.new(margin, margin, margin, margin)
- end
-
- instance_eval &blk if block_given?
- parent_container.add(container)
-
- super
- end
-end
-end
\ No newline at end of file
diff --git a/lib/brown_shoes/elements/layout.rb b/lib/brown_shoes/elements/layout.rb
deleted file mode 100644
index 444c6886..00000000
--- a/lib/brown_shoes/elements/layout.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-module Shoes
- class Layout
-
- # Descendant classes should configure their own instance
- # of Java Swing JPanel, which is exposed to the
- # &blk as 'container'. The Layout's own 'container'
- # is held as 'parent_container' for any future use of the Layout
- # itself.
- # super(parent_container) must be called *after* the Layout instance
- # has setup its own @container
- def initialize(parent_container, opts={}, &blk)
-
- end
-
- def flow(opts = {}, &blk)
- swt_flow = Shoes::Flow.new container, opts, &blk
- end
-
-
- def button(text, opts={}, &blk)
- button = Shoes::Button.new(container, text, opts, &blk)
- #@elements[button.to_s] = button
- #button
- end
-
-
- end
-end
diff --git a/lib/brown_shoes/elements/stack.rb b/lib/brown_shoes/elements/stack.rb
deleted file mode 100644
index 30fbad9e..00000000
--- a/lib/brown_shoes/elements/stack.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-module Shoes
-class Stack < Native
- 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
\ No newline at end of file
diff --git a/lib/shoes-archive.rb b/lib/shoes-archive.rb
new file mode 100644
index 00000000..19d47fce
--- /dev/null
+++ b/lib/shoes-archive.rb
@@ -0,0 +1,390 @@
+require 'java'
+
+require 'rubygems'
+require 'facets/hash'
+
+#require 'swt_shoes'
+
+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("Shoooes!")
+
+require 'shoes/configuration'
+Shoes.configuration.framework ||= 'swing'
+
+require 'shoes/base_object'
+
+
+
+require 'shoes/app'
+
+#require 'shoes/element_methods'
+#require 'shoes/layout'
+#require 'shoes/native'
+#require 'shoes/window'
+#require 'shoes/flow'
+#require 'shoes/button'
+#require 'shoes/animation'
+
+#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'
+
+module Shoes
+
+ include Log4jruby::LoggerForClass
+
+ def self.app(opts={}, &blk)
+ Shoes::App.new(opts, &blk)
+ logger.debug "Exiting Shoes.app"
+ end
+
+=begin
+ 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 "
#{k}
"
+ samples = []
+ v.each do |file|
+ sample = File.basename(file).split('-')[1..-1].join('-')[0..-4]
+ samples << "#{sample}"
+ 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.class_variable_get("@@types")[#{methc.dump}]
+ widget(*a, &b)
+ end
+ }
+ end
+ end
+=end
+
+end
+
+def window(*a, &b)
+ Shoes.app(*a, &b)
+end
diff --git a/lib/shoes-archive/animation.rb b/lib/shoes-archive/animation.rb
new file mode 100644
index 00000000..c3c1bb94
--- /dev/null
+++ b/lib/shoes-archive/animation.rb
@@ -0,0 +1,26 @@
+require 'shoes/timer_base'
+require 'shoes/runnable_block'
+
+module Shoes
+ class Animation < TimerBase
+
+ def initialize fps, &blk
+ ms_per_frame = 1000 / fps
+
+ if block_given?
+ @runnable = RunnableBlock.new(ms_per_frame, blk)
+
+ @runnable.init
+ end
+ end
+
+ def stop
+ @runnable.stop
+ end
+
+ def start
+ @runnable.start
+ end
+
+ end
+end
diff --git a/lib/shoes-archive/app.rb b/lib/shoes-archive/app.rb
new file mode 100644
index 00000000..1395051f
--- /dev/null
+++ b/lib/shoes-archive/app.rb
@@ -0,0 +1,99 @@
+#require 'shoes/window'
+
+module Shoes
+
+ # Shoes::App.new creates a new Shoes application window!
+ # The default window is a [flow]
+ #
+ class App < BaseObject
+
+ include Log4jruby::LoggerForClass
+
+ attr_accessor :elements, :framework_adapter
+ attr_accessor :main_shell
+
+ # Returns the framework_adapter for this class.
+ def framework_adapter_klass
+ framework_adapter_for('App')
+ end
+
+ attr_reader :frame, :container
+
+ import javax.swing.JPanel
+ import javax.swing.JFrame
+ import java.awt.Dimension
+ import java.awt.FlowLayout
+ import java.awt.BorderLayout
+ import javax.swing.BoxLayout
+
+ DEFAULT_HEIGHT = 600
+ DEFAULT_WIDTH = 800
+
+ def initialize(opts={}, &blk)
+ opts.stringify_keys!
+ height = opts['height'] ||= DEFAULT_HEIGHT
+ width = opts['width'] ||= DEFAULT_WIDTH
+
+ @elements = {}
+ @frame = JFrame.new()
+
+ @container = @frame.get_content_pane
+
+ @layout = FlowLayout.new(FlowLayout::LEFT)
+ #@layout.alignment = FlowLayout::LEFT
+ @frame.setLayout(@layout)
+
+ #flow(opts, &blk)
+ instance_eval &blk
+
+ @frame.setDefaultCloseOperation(JFrame::EXIT_ON_CLOSE)
+ #@container.border = javax.swing.border.LineBorder.new(java.awt.Color::BLUE, 4, true)
+ @container.setBackground(java.awt.Color::BLUE)
+
+ #@frame.pack()
+ if opts['pack']
+ @frame.pack
+ else
+ @frame.setSize(Dimension.new(opts['width'], opts['height']))
+ @container.setSize(Dimension.new(opts['width'], opts['height']))
+ end
+ @frame.set_visible(true)
+
+ #debugger; 1
+
+ end
+
+
+ #def initialize(opts={}, &blk)
+ # #debugger
+ #
+ # @framework_adapter = self.framework_adapter_klass.new opts, &blk
+ #
+ # debugger; 1
+ #
+ # #def swt_implementation
+ # #@elements = {}
+ # #
+ # #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
+ # #
+ # #Swt.event_loop { Swt.display.isDisposed }
+ # #
+ # #logger.debug "Swt.display disposed... exiting Shoes::App.new"
+ # #end
+ #end
+
+ #private
+ #def main_window_on_close
+ # lambda {
+ # logger.debug "main_window on_close block begin... disposing Swt.display"
+ # Swt.display.dispose
+ # logger.debug "Swt.display disposed"
+ # }
+ #end
+ end
+end
\ No newline at end of file
diff --git a/lib/shoes/archive/elements/check.html b/lib/shoes-archive/archive/elements/check.html
similarity index 100%
rename from lib/shoes/archive/elements/check.html
rename to lib/shoes-archive/archive/elements/check.html
diff --git a/lib/brown_shoes/elements/check.rb b/lib/shoes-archive/archive/elements/check.rb
similarity index 100%
rename from lib/brown_shoes/elements/check.rb
rename to lib/shoes-archive/archive/elements/check.rb
diff --git a/lib/shoes/archive/elements/edit_box.html b/lib/shoes-archive/archive/elements/edit_box.html
similarity index 100%
rename from lib/shoes/archive/elements/edit_box.html
rename to lib/shoes-archive/archive/elements/edit_box.html
diff --git a/lib/brown_shoes/elements/edit_box.rb b/lib/shoes-archive/archive/elements/edit_box.rb
similarity index 100%
rename from lib/brown_shoes/elements/edit_box.rb
rename to lib/shoes-archive/archive/elements/edit_box.rb
diff --git a/lib/shoes/archive/elements/edit_line.html b/lib/shoes-archive/archive/elements/edit_line.html
similarity index 100%
rename from lib/shoes/archive/elements/edit_line.html
rename to lib/shoes-archive/archive/elements/edit_line.html
diff --git a/lib/brown_shoes/elements/edit_line.rb b/lib/shoes-archive/archive/elements/edit_line.rb
similarity index 100%
rename from lib/brown_shoes/elements/edit_line.rb
rename to lib/shoes-archive/archive/elements/edit_line.rb
diff --git a/lib/shoes/archive/elements/element.html b/lib/shoes-archive/archive/elements/element.html
similarity index 100%
rename from lib/shoes/archive/elements/element.html
rename to lib/shoes-archive/archive/elements/element.html
diff --git a/lib/shoes/archive/elements/element.rb b/lib/shoes-archive/archive/elements/element.rb
similarity index 100%
rename from lib/shoes/archive/elements/element.rb
rename to lib/shoes-archive/archive/elements/element.rb
diff --git a/lib/shoes/archive/elements/image.html b/lib/shoes-archive/archive/elements/image.html
similarity index 100%
rename from lib/shoes/archive/elements/image.html
rename to lib/shoes-archive/archive/elements/image.html
diff --git a/lib/brown_shoes/elements/image.rb b/lib/shoes-archive/archive/elements/image.rb
similarity index 100%
rename from lib/brown_shoes/elements/image.rb
rename to lib/shoes-archive/archive/elements/image.rb
diff --git a/lib/shoes/archive/elements/stack.html b/lib/shoes-archive/archive/elements/stack.html
similarity index 100%
rename from lib/shoes/archive/elements/stack.html
rename to lib/shoes-archive/archive/elements/stack.html
diff --git a/lib/shoes/archive/elements/stack.rb b/lib/shoes-archive/archive/elements/stack.rb
similarity index 100%
rename from lib/shoes/archive/elements/stack.rb
rename to lib/shoes-archive/archive/elements/stack.rb
diff --git a/lib/shoes/archive/shoooes b/lib/shoes-archive/archive/shoooes
similarity index 100%
rename from lib/shoes/archive/shoooes
rename to lib/shoes-archive/archive/shoooes
diff --git a/lib/shoes/archive/shoooesd b/lib/shoes-archive/archive/shoooesd
similarity index 100%
rename from lib/shoes/archive/shoooesd
rename to lib/shoes-archive/archive/shoooesd
diff --git a/lib/shoes/archive/window.rb b/lib/shoes-archive/archive/window.rb
similarity index 100%
rename from lib/shoes/archive/window.rb
rename to lib/shoes-archive/archive/window.rb
diff --git a/lib/shoes-archive/base_object.rb b/lib/shoes-archive/base_object.rb
new file mode 100644
index 00000000..cab390ae
--- /dev/null
+++ b/lib/shoes-archive/base_object.rb
@@ -0,0 +1,9 @@
+require 'shoes/framework_adapters/framework_adapter_support'
+
+module Shoes
+class BaseObject
+ # All RuGUI objects clan have access to framework adapters.
+ include Shoes::FrameworkAdapters::FrameworkAdapterSupport
+
+end
+end
diff --git a/lib/shoes/config_logger.rb b/lib/shoes-archive/config_logger.rb
similarity index 100%
rename from lib/shoes/config_logger.rb
rename to lib/shoes-archive/config_logger.rb
diff --git a/lib/shoes-archive/configuration.rb b/lib/shoes-archive/configuration.rb
new file mode 100644
index 00000000..7b800bec
--- /dev/null
+++ b/lib/shoes-archive/configuration.rb
@@ -0,0 +1,17 @@
+module Shoes
+ class Configuration
+ class << self
+ attr_accessor :framework
+
+ def framework=(value)
+ @framework = value
+ require "shoes/framework_adapters/#{value}"
+ end
+ end
+
+ end
+end
+
+def Shoes.configuration
+ Shoes::Configuration
+end
diff --git a/lib/shoes-archive/element_methods.rb b/lib/shoes-archive/element_methods.rb
new file mode 100644
index 00000000..03b90abc
--- /dev/null
+++ b/lib/shoes-archive/element_methods.rb
@@ -0,0 +1,50 @@
+module Shoes
+ module ElementMethods
+
+ #def stack(opts={}, &blk)
+ # tstack = Stack.new(opts)
+ # layout(tstack, &blk)
+ #end
+
+ def flow(opts = {}, &blk)
+ swt_flow = Shoes::Flow.new(container, opts, &blk)
+ end
+
+
+ def button(text, opts={}, &blk)
+ button = Shoes::Button.new(container, text, opts, &blk)
+ #@elements[button.to_s] = button
+ #button
+ end
+
+ def animate(fps = 10, &blk)
+ anim = Shoes::Animation.new(fps, &blk)
+ 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
+ #
+ end
+end
\ No newline at end of file
diff --git a/lib/shoes-archive/flow.rb b/lib/shoes-archive/flow.rb
new file mode 100644
index 00000000..539918dc
--- /dev/null
+++ b/lib/shoes-archive/flow.rb
@@ -0,0 +1,17 @@
+require 'shoes/layout'
+
+# flow takes these options
+# :margin - integer - add this many pixels to all 4 sides of the layout
+module Shoes
+ class Flow < Layout
+
+ # container - holds the widgets and controls painting
+ # layout - directs the container on _where_ to place widgets
+ attr_reader :container, :layout
+
+ def initialize composite_parent, opts = {}, &blk
+ super
+ end
+
+ end
+end
diff --git a/lib/shoes-archive/framework_adapter_support.rb b/lib/shoes-archive/framework_adapter_support.rb
new file mode 100644
index 00000000..74c2bd37
--- /dev/null
+++ b/lib/shoes-archive/framework_adapter_support.rb
@@ -0,0 +1,38 @@
+ require 'shoes/framework_adapters/base_framework_adapter'
+require 'facets/string'
+require 'facets/kernel/constant'
+
+module Shoes
+ module FrameworkAdapters
+ module FrameworkAdapterSupport
+ def framework_adapter_for(class_name)
+ @framework_adapter ||= {}
+ load_framework_adapter(class_name) unless @framework_adapter[class_name]
+ @framework_adapter[class_name]
+ end
+
+ def load_framework_adapter(class_name)
+ #@framework_adapter[class_name] = class_adapter_for(class_name).new(self)
+ @framework_adapter[class_name] = class_adapter_for(class_name)
+ end
+
+ module CommonClassAndInstanceMethods
+ def adapter_module_name(framework_adapter = Shoes.configuration.framework)
+ "Shoes::FrameworkAdapters::#{framework_adapter.camelcase}"
+ end
+
+ def class_adapter_for(class_name)
+ constant("#{adapter_module_name}::#{class_name}")
+ rescue
+ # Fallback to the base_framework_adapter.
+ constant("#{adapter_module_name('base_framework_adapter')}::#{class_name}")
+ end
+ end
+
+ def self.included(base)
+ base.send(:include, CommonClassAndInstanceMethods)
+ base.extend(CommonClassAndInstanceMethods)
+ end
+ end
+ end
+end
diff --git a/lib/brown_shoes/elements/native.rb b/lib/shoes-archive/native.rb
similarity index 78%
rename from lib/brown_shoes/elements/native.rb
rename to lib/shoes-archive/native.rb
index d794806f..2372979c 100644
--- a/lib/brown_shoes/elements/native.rb
+++ b/lib/shoes-archive/native.rb
@@ -1,20 +1,13 @@
module Shoes
class Native
+ include Log4jruby::LoggerForClass
- #TODO: make this attr_accessor :identifier ??
- # Needs to be inheritable
- #def identifier
- # @identifier
- #end
+ attr_reader :native_widget, :container
- #TODO: make this attr_accessor :native_widget ??
- # Needs to be inheritable
- #def native_widget
- # @native_widget
- #end
+ # default initializer for calls to
+ # super(opts) from descendant classes
+ def initialize(opts = {})
- def initialize(opts={})
- @identifier = opts[:id]
end
# This is the position of the Element from the top
@@ -76,15 +69,17 @@ def toggle
# displace(left: a number, top: a number) » self
# Displacing an element moves it. But without changing the layout around it.
def displace(left, top)
- @swt_widget.setLocation(bounds.x + left, bounds.y + top)
- #@swt_composite.pack
+ unless native_widget.isDisposed
+ logger.debug "#{self.inspect} displace top:#{top} left:#{left}"
+ native_widget.setLocation(bounds.x + left, bounds.y + top)
+ container.pack(false)
+ end
end
private
def bounds
- @native_widget ||= @native_widget.getBounds
+ @bounds ||= native_widget.getBounds
end
-
end
-end
\ No newline at end of file
+end
diff --git a/lib/shoes-archive/runnable_block.rb b/lib/shoes-archive/runnable_block.rb
new file mode 100644
index 00000000..71b244e2
--- /dev/null
+++ b/lib/shoes-archive/runnable_block.rb
@@ -0,0 +1,46 @@
+module Shoes
+
+# Runnable is a Java interface(?) that provides a container
+# object for SWT::Display.timerExec. .timerExec() internally
+# creates a thread to call runnable.run. We'll use a class here
+# to encapsulate some of the data-passing required in the Thread
+# boundary inside .timerExec()
+ class RunnableBlock
+ def initialize(ms_per_frame, block)
+ @ms_per_frame = ms_per_frame
+ @frame = 1
+ @block = block
+ end
+
+ def init
+ set_next_timer
+ end
+
+ def stop
+ @stop = true
+ end
+
+ def start
+ if @stop
+ @stop = nil
+ run
+ end
+ end
+
+ def run
+ # This extra call to timerExec is what keeps the "loop" running.
+ # every execution of #run re-sets the timer for the next execution.
+ # The timer for the next-loop is started here so that timing between
+ # loops is not delayed by processing the loop code. Hopefully the
+ # @block.call finishes in time!
+ set_next_timer
+
+ @block[@frame]
+ @frame += 1
+ end
+ def set_next_timer
+ Swt.display.timer_exec(@ms_per_frame, self) unless @stop
+ end
+ end
+
+end
diff --git a/lib/shoes-archive/stack.rb b/lib/shoes-archive/stack.rb
new file mode 100644
index 00000000..249ce205
--- /dev/null
+++ b/lib/shoes-archive/stack.rb
@@ -0,0 +1,18 @@
+require 'shoes/layout'
+
+# flow takes these options
+# :margin - integer - add this many pixels to all 4 sides of the layout
+module Shoes
+ class Stack < Layout
+
+ # container - holds the widgets and controls painting
+ # layout - directs the container on _where_ to place widgets
+ attr_reader :container, :layout
+
+ def initialize composite_parent, opts = {}, &blk
+ opts['layout_type'] = Swt::SWT::VERTICAL
+ super
+ end
+
+ end
+end
diff --git a/lib/shoes/swt_constants.rb b/lib/shoes-archive/swt_constants.rb
similarity index 100%
rename from lib/shoes/swt_constants.rb
rename to lib/shoes-archive/swt_constants.rb
diff --git a/lib/shoes-archive/timer_base.rb b/lib/shoes-archive/timer_base.rb
new file mode 100644
index 00000000..4b6aac9c
--- /dev/null
+++ b/lib/shoes-archive/timer_base.rb
@@ -0,0 +1,5 @@
+module Shoes
+ class TimerBase
+ # To change this template use File | Settings | File Templates.
+ end
+end
\ No newline at end of file
diff --git a/lib/shoes/window.rb b/lib/shoes-archive/window.rb
similarity index 76%
rename from lib/shoes/window.rb
rename to lib/shoes-archive/window.rb
index dfd8cc08..e657e2ad 100644
--- a/lib/shoes/window.rb
+++ b/lib/shoes-archive/window.rb
@@ -3,22 +3,21 @@
module Shoes
class Window < Layout
- DEFAULT_WIDTH = 800
- DEFAULT_HEIGHT = 600
- DEFAULT_TITLE = "Shooes!"
-
attr_reader :container
+ import org.eclipse.swt.graphics.Color
+
def initialize(opts = {}, &blk)
opts.stringify_keys!
@elements = opts['elements']
- @container = Swt::Widgets::Shell.new($display, Swt::SWT::CLOSE)
+ @container = Swt::Widgets::Shell.new(Swt.display, Swt::SWT::CLOSE)
width, height = opts['width'] || DEFAULT_WIDTH, opts['height'] || DEFAULT_HEIGHT
@container.setSize(width, height)
@container.setText(opts['title'] || DEFAULT_TITLE)
+ @container.setBackground(Color.new(Swt.display, 50, 0, 0))
if opts['on_close']
logger.debug "Shell #{@container.inspect} adding block #{blk.inspect}"
@@ -26,7 +25,7 @@ def initialize(opts = {}, &blk)
end
instance_eval &blk if block_given?
- #@container.pack
+ @container.pack
@container.open
end
diff --git a/lib/shoes.rb b/lib/shoes.rb
index d85dc43f..fe8eb7ba 100644
--- a/lib/shoes.rb
+++ b/lib/shoes.rb
@@ -3,7 +3,7 @@
require 'rubygems'
require 'facets/hash'
-require 'swt'
+#$:<< 'lib/shoes'
require 'lib/log4j/log4j-1.2.16.jar'
require 'log4jruby'
@@ -11,372 +11,25 @@
logger = Log4jruby::Logger.get('test', :tracing => true, :level => :debug )
logger.debug("Shoooes!")
-require 'shoes/app'
-require 'shoes/element_methods'
-require 'shoes/layout'
-require 'shoes/native'
-require 'shoes/window'
-require 'shoes/flow'
-require 'shoes/button'
-require 'shoes/animation'
-
-#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'
-
-module Shoes
-
- include Log4jruby::LoggerForClass
-
- def self.app(opts={}, &blk)
- Shoes::App.new(opts, &blk)
- logger.debug "Exiting Shoes.app"
- end
-
-=begin
- 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 "#{k}
"
- samples = []
- v.each do |file|
- sample = File.basename(file).split('-')[1..-1].join('-')[0..-4]
- samples << "#{sample}"
- 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
+require 'shoes/configuration'
+Shoes.configuration.framework ||= 'swing_shoes'
- def self.mount(path, meth, &blk)
- @mounts << [path, meth || blk]
- end
+require 'shoes/base_object'
- 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.class_variable_get("@@types")[#{methc.dump}]
- widget(*a, &b)
- end
- }
- end
- end
-=end
-
-end
+require 'shoes/app'
+#require 'shoes/native'
+#require 'shoes/element_methods'
+#require 'shoes/animation'
+#require 'shoes/runnable_block'
+#require 'shoes/timer_base'
+#require 'shoes/layout'
+#require 'shoes/button'
+#require 'shoes/stack'
+#require 'shoes/flow'
+#require 'shoes/edit_line'
+#require 'shoes/edit_box'
+#require 'shoes/check'
+#require 'shoes/image'
-def window(*a, &b)
- Shoes.app(*a, &b)
-end
diff --git a/lib/shoes/animation.rb b/lib/shoes/animation.rb
index c3c1bb94..741b6450 100644
--- a/lib/shoes/animation.rb
+++ b/lib/shoes/animation.rb
@@ -1,25 +1,33 @@
require 'shoes/timer_base'
-require 'shoes/runnable_block'
+#require 'runnable_block'
module Shoes
class Animation < TimerBase
- def initialize fps, &blk
+ import javax.swing.Timer
+
+ attr_reader :jtimer
+
+ def initialize this, fps, &blk
ms_per_frame = 1000 / fps
if block_given?
- @runnable = RunnableBlock.new(ms_per_frame, blk)
+ @runnable = RunnableBlock.new(this, blk)
+ @jtimer = Timer.new(ms_per_frame, @runnable )
- @runnable.init
+ #@runnable.init
+ @jtimer.start
end
end
def stop
- @runnable.stop
+ #@runnable.stop
+ @jtimer.stop
end
def start
- @runnable.start
+ #@runnable.start
+ @jtimer.start
end
end
diff --git a/lib/shoes/app.rb b/lib/shoes/app.rb
index ab90f71a..f56821c7 100644
--- a/lib/shoes/app.rb
+++ b/lib/shoes/app.rb
@@ -1,40 +1,123 @@
-require 'shoes'
-require 'swt'
+require 'shoes/element_methods'
+
+def window(*a, &b)
+ Shoes.app(*a, &b)
+end
+
module Shoes
- # Shoes::App.new creates a new Shoes application window!
- # The default window is a [flow]
- #
- class App
- include Log4jruby::LoggerForClass
+ def self.app(opts={}, &blk)
+ Shoes::App.new(opts, &blk)
+ end
- attr_accessor :elements, :frame
- attr_accessor :main_shell
+ class App < BaseObject
+ include Shoes::ElementMethods
+
+ attr_accessor :elements, :framework_adapter
def initialize(opts={}, &blk)
- @elements = {}
+ #debugger
+
+ @framework_adapter = self.framework.new opts, &blk
+
+ puts "Framework Adapter initialized"
+
+ end
+
+ #import javax.swing.JPanel
+ #import javax.swing.JFrame
+ #import java.awt.Dimension
+ #import java.awt.FlowLayout
+ #import java.awt.BorderLayout
+ #import javax.swing.BoxLayout
+ #
+ #DEFAULT_HEIGHT = 600
+ #DEFAULT_WIDTH = 800
+ #
+ #
+ #def xinitialize(opts={}, &blk)
+ # opts.stringify_keys!
+ # height = opts['height'] ||= DEFAULT_HEIGHT
+ # width = opts['width'] ||= DEFAULT_WIDTH
+ #
+ # @elements = {}
+ # @frame = JFrame.new()
+ #
+ # @container = @frame.get_content_pane
+ #
+ # @layout = FlowLayout.new(FlowLayout::LEFT)
+ # #@layout.alignment = FlowLayout::LEFT
+ # @frame.setLayout(@layout)
+ #
+ # #flow(opts, &blk)
+ # instance_eval &blk
+ #
+ # @frame.setDefaultCloseOperation(JFrame::EXIT_ON_CLOSE)
+ # #@container.border = javax.swing.border.LineBorder.new(java.awt.Color::BLUE, 4, true)
+ # @container.setBackground(java.awt.Color::BLUE)
+ #
+ # #@frame.pack()
+ # if opts['pack']
+ # @frame.pack
+ # else
+ # @frame.setSize(Dimension.new(opts['width'], opts['height']))
+ # @container.setSize(Dimension.new(opts['width'], opts['height']))
+ # end
+ # @frame.set_visible(true)
+ #
+ # #debugger; 1
+ #
+ #end
- 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
+ #def button(opts={}, &blk)
+ #
+ # button = Button.new(@current_panel,opts, &blk)
+ # @elements[button.identifier] = button
+ # button
+ #end
- Swt.event_loop { Swt.display.isDisposed }
+ 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
- logger.debug "Swt.display disposed... exiting Shoes::App.new"
+ def flow(opts={}, &blk)
+ tflow = Flow.new(@container, opts, &blk)
+ #layout(tflow, &blk)
end
- private
- def main_window_on_close
- lambda {
- logger.debug "main_window on_close block begin... disposing Swt.display"
- Swt.display.dispose
- logger.debug "Swt.display disposed"
- }
+ def layout(layer, &blk)
+ parent = @current_panel
+ @current_panel = layer.panel
+ instance_eval &blk
+ parent.add(@current_panel)
+ @current_panel = parent
end
end
end
\ No newline at end of file
diff --git a/lib/shoes/base_object.rb b/lib/shoes/base_object.rb
new file mode 100644
index 00000000..7343059b
--- /dev/null
+++ b/lib/shoes/base_object.rb
@@ -0,0 +1,22 @@
+require 'facets/kernel/constant'
+require 'facets/string'
+
+module Shoes
+ class BaseObject
+
+ def framework
+
+ begin
+ framework_klass = Shoes.configuration.framework.camelcase + "::#{self.class.to_s}"
+ constant(framework_klass)
+ rescue NameError
+ unless @tried
+ require "shoes/framework_adapters/#{Shoes.configuration.framework}"
+ @tried = true
+ retry
+ end
+ end
+
+ end
+ end
+end
diff --git a/lib/shoes/button.rb b/lib/shoes/button.rb
index 35928cbf..49640642 100644
--- a/lib/shoes/button.rb
+++ b/lib/shoes/button.rb
@@ -1,17 +1,17 @@
-require 'shoes/native'
-
+#debugger
+#require 'native'
module Shoes
class Button < Native
- # Create a button on the specified _shell_
- def initialize(container, text, opts = {}, &blk)
- @container = container
- @native_widget = Swt::Widgets::Button.new(@container, Swt::SWT::PUSH)
- @native_widget.setText(text)
- #@native_widget.setBounds(10, 10, 150, 30)
- @native_widget.addSelectionListener(&blk) if block_given?
- @native_widget.pack
+ attr_accessor :native_widget
+
+ def initialize(parent, text = 'Button', opts={}, &blk)
+ super(opts)
+ @native_widget = javax.swing.JButton.new(text)
+ @native_widget.add_action_listener(&blk) unless blk.nil?
+ parent.add(@native_widget)
+ return self
end
end
-end
+end
\ No newline at end of file
diff --git a/lib/shoes/archive/elements/check.rb b/lib/shoes/check.rb
similarity index 100%
rename from lib/shoes/archive/elements/check.rb
rename to lib/shoes/check.rb
diff --git a/lib/shoes/configuration.rb b/lib/shoes/configuration.rb
new file mode 100644
index 00000000..7b800bec
--- /dev/null
+++ b/lib/shoes/configuration.rb
@@ -0,0 +1,17 @@
+module Shoes
+ class Configuration
+ class << self
+ attr_accessor :framework
+
+ def framework=(value)
+ @framework = value
+ require "shoes/framework_adapters/#{value}"
+ end
+ end
+
+ end
+end
+
+def Shoes.configuration
+ Shoes::Configuration
+end
diff --git a/lib/shoes/archive/elements/edit_box.rb b/lib/shoes/edit_box.rb
similarity index 100%
rename from lib/shoes/archive/elements/edit_box.rb
rename to lib/shoes/edit_box.rb
diff --git a/lib/shoes/archive/elements/edit_line.rb b/lib/shoes/edit_line.rb
similarity index 100%
rename from lib/shoes/archive/elements/edit_line.rb
rename to lib/shoes/edit_line.rb
diff --git a/lib/shoes/element_methods.rb b/lib/shoes/element_methods.rb
index bf81d8d2..e730d98e 100644
--- a/lib/shoes/element_methods.rb
+++ b/lib/shoes/element_methods.rb
@@ -1,6 +1,56 @@
+#require 'animation'
+
+#require 'native'
+#require 'button'
+#require 'flow'
+
module Shoes
module ElementMethods
+ #def stack(opts={}, &blk)
+ # tstack = Stack.new(opts)
+ # layout(tstack, &blk)
+ #end
+
+ def flow(opts = {}, &blk)
+ swt_flow = Shoes::Flow.new(container, opts, &blk)
+ end
+
+
+ def button(text, opts={}, &blk)
+ button = Shoes::Button.new(container, text, opts, &blk)
+ #@elements[button.to_s] = button
+ #button
+ end
+
+ def animate(fps = 10, &blk)
+ anim = Shoes::Animation.new(self, fps, &blk)
+ 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
+ #
end
end
\ No newline at end of file
diff --git a/lib/shoes/flow.rb b/lib/shoes/flow.rb
index a099644a..79c401aa 100644
--- a/lib/shoes/flow.rb
+++ b/lib/shoes/flow.rb
@@ -1,40 +1,43 @@
require 'shoes/layout'
-# flow takes these options
-# :margin - integer - add this many pixels to all 4 sides of the layout
module Shoes
- class Flow < Layout
-
- # container - holds the widgets and controls painting
- # layout - directs the container on _where_ to place widgets
- attr_reader :container, :layout
-
- def initialize composite_parent, opts = {}, &blk
- @container = Swt::Widgets::Composite.new(composite_parent, Swt::SWT::NONE)
-
- # RowLayout is horizontal by default, wrapping by default
- @layout = Swt::Layout::RowLayout.new
-
- # set the margins
- margin(opts[:margin]) if opts[:margin]
-
- if opts['width'] && opts['height']
- @container.setSize(opts['width'], opts['height'])
- end
-
- @container.setLayout(@layout)
-
- instance_eval &blk if block_given?
-
- @container.pack
+class Flow < Layout
+ import java.awt.BorderLayout
+ import java.awt.Dimension
+ import java.awt.FlowLayout
+ import javax.swing.JPanel
+ import javax.swing.BoxLayout
+
+ import javax.swing.border.EmptyBorder
+
+ attr_accessor :parent_container, :container
+
+ def initialize(parent_container, opts={}, &blk)
+ opts.stringify_keys!
+ @parent_container = parent_container
+ @container = JPanel.new()
+ #layout = BoxLayout.new(@container, BoxLayout::LINE_AXIS)
+ layout = FlowLayout.new
+ layout.alignment = FlowLayout::LEFT
+
+ @container.set_layout(layout)
+ #debugger
+ unless parent_container.is_a? BorderLayout
+ if(opts['height'] && opts['width'])
+ #@container.set_preferred_size(Dimension.new(opts['width'], opts['height']))
end
-
- # Add this many pixels to margins on layout
- def margin(margin_pixels)
- @layout.marginTop = margin_pixels
- @layout.marginRight = margin_pixels
- @layout.marginBottom = margin_pixels
- @layout.marginLeft = margin_pixels
end
+
+ if margin = opts['margin']
+ #@container.border = EmptyBorder.new(margin, margin, margin, margin)
+ #@container.border = javax.swing.border.LineBorder.new(java.awt.Color::RED, 2, true)
+ @container.setBackground(java.awt.Color::PINK)
+ end
+
+ instance_eval &blk if block_given?
+ parent_container.add(container, BorderLayout::CENTER)
+
+ super
end
end
+end
\ No newline at end of file
diff --git a/lib/shoes/framework_adapters/base_framework_adapter.rb b/lib/shoes/framework_adapters/base_framework_adapter.rb
new file mode 100644
index 00000000..60303d38
--- /dev/null
+++ b/lib/shoes/framework_adapters/base_framework_adapter.rb
@@ -0,0 +1,106 @@
+module BaseFrameworkAdapter
+ module Shoes
+ class Base
+ attr_accessor :adapted_object
+
+ def initialize(adapted_object)
+ self.adapted_object = adapted_object
+ end
+ end
+
+ ## Adapts the BaseController methods specific for the framework.
+ #class BaseController < Base
+ # # Queues the block call, so that it is only gets executed in the main thread.
+ # def queue(&block)
+ # end
+ #end
+
+ # Adapter Template for the BaseApp methods specific for the framework.
+ class App < Base
+
+ def initialize(opts={}, &blk)
+ end
+
+ # Returns the framework_adapter for this class.
+ def framework_adapter
+ framework_adapter_for('App')
+ end
+
+
+ # Runs the application, starting anything the framework needs.
+ def run
+ end
+
+ # Refreshes the GUI application, running just one event loop.
+ #
+ # This method is mostly useful when writing tests. It shouldn't be used
+ # in normal applications.
+ def refresh
+ end
+
+ # Exits the application, freeing any resources used by the framework.
+ def quit
+ end
+ end
+
+ ## Adapts the BaseModel methods specific for the framework
+ #class BaseElement < Base
+ #end
+
+ # Adapts the BaseView methods specific for the framework
+ class BaseNative < Base
+ # Queues the block call, so that it is only gets executed in the main thread.
+ def queue(&block)
+ end
+
+ # Adds a widget to the given container widget.
+ def add_widget_to_container(widget, container_widget)
+ end
+
+ # Removes a widget from the given container widget.
+ def remove_widget_from_container(widget, container_widget)
+ end
+
+ # Removes all children from the given container widget.
+ def remove_all_children(container_widget)
+ end
+
+ # Sets the widget name for the given widget if given.
+ def set_widget_name(widget, widget_name)
+ end
+
+ # Autoconnects signals handlers for the view. If +other_target+ is given
+ # it is used instead of the view itself.
+ def autoconnect_signals(view, other_target = nil)
+ end
+
+ # Connects the signal from the widget to the given receiver block.
+ # The block is executed in the context of the receiver.
+ def connect_declared_signal_block(widget, signal, receiver, block)
+ end
+
+ # Connects the signal from the widget to the given receiver method.
+ def connect_declared_signal(widget, signal, receiver, method)
+ end
+
+ # Builds widgets from the given filename, using the proper builder.
+ def build_widgets_from(filename)
+ end
+
+ # Registers widgets as attributes of the view class.
+ def register_widgets
+ end
+
+ class << self
+ # Returns the builder file extension to be used for this view class.
+ def builder_file_extension
+ end
+ end
+ end
+
+ ## Adapts the BaseViewHelper methods specific for the framework
+ #class BaseViewHelper
+ #end
+ end
+end
+
diff --git a/lib/shoes/framework_adapters/swing_shoes.rb b/lib/shoes/framework_adapters/swing_shoes.rb
new file mode 100644
index 00000000..03d9a4b6
--- /dev/null
+++ b/lib/shoes/framework_adapters/swing_shoes.rb
@@ -0,0 +1,12 @@
+require 'shoes/framework_adapters/white_shoes'
+
+require 'shoes/framework_adapters/swing_shoes/app'
+
+module SwingShoes
+ module Shoes
+
+ end
+
+end
+
+
diff --git a/lib/shoes/framework_adapters/swing_shoes/app.rb b/lib/shoes/framework_adapters/swing_shoes/app.rb
new file mode 100644
index 00000000..8b418077
--- /dev/null
+++ b/lib/shoes/framework_adapters/swing_shoes/app.rb
@@ -0,0 +1,54 @@
+
+module SwingShoes
+ module Shoes
+
+ class App < WhiteShoes::Shoes::App
+
+ attr_reader :frame, :container
+
+ import javax.swing.JPanel
+ import javax.swing.JFrame
+ import java.awt.Dimension
+ import java.awt.FlowLayout
+ import java.awt.BorderLayout
+ import javax.swing.BoxLayout
+
+ DEFAULT_HEIGHT = 600
+ DEFAULT_WIDTH = 800
+
+ def initialize(opts={}, &blk)
+ opts.stringify_keys!
+ height = opts['height'] ||= DEFAULT_HEIGHT
+ width = opts['width'] ||= DEFAULT_WIDTH
+
+ @elements = {}
+ @frame = JFrame.new()
+
+ @container = @frame.get_content_pane
+
+ @layout = FlowLayout.new(FlowLayout::LEFT)
+ #@layout.alignment = FlowLayout::LEFT
+ @frame.setLayout(@layout)
+
+ #flow(opts, &blk)
+ instance_eval &blk if block_given?
+
+ @frame.setDefaultCloseOperation(JFrame::EXIT_ON_CLOSE)
+ #@container.border = javax.swing.border.LineBorder.new(java.awt.Color::BLUE, 4, true)
+ @container.setBackground(java.awt.Color::BLUE)
+
+ #@frame.pack()
+ if opts['pack']
+ @frame.pack
+ else
+ @frame.setSize(Dimension.new(opts['width'], opts['height']))
+ @container.setSize(Dimension.new(opts['width'], opts['height']))
+ end
+ @frame.set_visible(true)
+
+ #debugger; 1
+
+ end
+ end
+ end
+end
diff --git a/lib/shoes/framework_adapters/swt_shoes.rb b/lib/shoes/framework_adapters/swt_shoes.rb
new file mode 100644
index 00000000..0ca75156
--- /dev/null
+++ b/lib/shoes/framework_adapters/swt_shoes.rb
@@ -0,0 +1,32 @@
+require 'shoes/framework_adapters/white_shoes'
+
+require 'rubygems'
+require 'swt'
+
+def window(*a, &b)
+ Shoes.app(*a, &b)
+end
+
+require 'shoes/framework_adapters/swt_shoes/app'
+require 'shoes/framework_adapters/swt_shoes/element_methods'
+require 'shoes/framework_adapters/swt_shoes/layout'
+require 'shoes/framework_adapters/swt_shoes/window'
+require 'shoes/framework_adapters/swt_shoes/flow'
+
+module SwtShoes
+ module Shoes
+
+
+ include Log4jruby::LoggerForClass
+
+ def self.app(opts={}, &blk)
+ Shoes::App.new(opts, &blk)
+ logger.debug "Exiting Shoes.app"
+ end
+
+
+ end
+
+end
+
+
diff --git a/lib/shoes/framework_adapters/swt_shoes/app.rb b/lib/shoes/framework_adapters/swt_shoes/app.rb
new file mode 100644
index 00000000..9b0289ad
--- /dev/null
+++ b/lib/shoes/framework_adapters/swt_shoes/app.rb
@@ -0,0 +1,46 @@
+require 'shoes'
+require 'swt'
+
+#require 'shoes/framework_adapters/swt_shoes/window'
+
+module SwtShoes
+
+ module Shoes
+
+ # Shoes::App.new creates a new Shoes application window!
+ # The default window is a [flow]
+ #
+ class App < WhiteShoes::Shoes::App
+
+ include Log4jruby::LoggerForClass
+
+ attr_accessor :elements, :frame
+ attr_accessor :main_shell
+
+
+ def initialize(opts={}, &blk)
+ @elements = {}
+
+ 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
+
+ Swt.event_loop { Swt.display.isDisposed }
+
+ logger.debug "Swt.display disposed... exiting Shoes::App.new"
+ end
+
+ private
+ def main_window_on_close
+ lambda {
+ logger.debug "main_window on_close block begin... disposing Swt.display"
+ Swt.display.dispose
+ logger.debug "Swt.display disposed"
+ }
+ end
+ end
+ end
+end
diff --git a/lib/shoes/framework_adapters/swt_shoes/button.rb b/lib/shoes/framework_adapters/swt_shoes/button.rb
new file mode 100644
index 00000000..35928cbf
--- /dev/null
+++ b/lib/shoes/framework_adapters/swt_shoes/button.rb
@@ -0,0 +1,17 @@
+require 'shoes/native'
+
+module Shoes
+ class Button < Native
+
+ # Create a button on the specified _shell_
+ def initialize(container, text, opts = {}, &blk)
+ @container = container
+ @native_widget = Swt::Widgets::Button.new(@container, Swt::SWT::PUSH)
+ @native_widget.setText(text)
+ #@native_widget.setBounds(10, 10, 150, 30)
+ @native_widget.addSelectionListener(&blk) if block_given?
+ @native_widget.pack
+ end
+
+ end
+end
diff --git a/lib/shoes/framework_adapters/swt_shoes/element_methods.rb b/lib/shoes/framework_adapters/swt_shoes/element_methods.rb
new file mode 100644
index 00000000..8920e20a
--- /dev/null
+++ b/lib/shoes/framework_adapters/swt_shoes/element_methods.rb
@@ -0,0 +1,54 @@
+#require 'shoes/framework_adapters/swt_shoes/flow'
+
+module SwtShoes
+ module Shoes
+ module ElementMethods
+
+ #def stack(opts={}, &blk)
+ # tstack = Stack.new(opts)
+ # layout(tstack, &blk)
+ #end
+
+ def flow(opts = {}, &blk)
+ swt_flow = SwtShoes::Shoes::Flow.new(container, opts, &blk)
+ end
+
+ #
+ #def button(text, opts={}, &blk)
+ # button = Shoes::Button.new(container, text, opts, &blk)
+ # #@elements[button.to_s] = button
+ # #button
+ #end
+ #
+ #def animate(fps = 10, &blk)
+ # anim = Shoes::Animation.new(fps, &blk)
+ #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
+ #
+ end
+ end
+end
diff --git a/lib/shoes/framework_adapters/swt_shoes/flow.rb b/lib/shoes/framework_adapters/swt_shoes/flow.rb
new file mode 100644
index 00000000..2400a99d
--- /dev/null
+++ b/lib/shoes/framework_adapters/swt_shoes/flow.rb
@@ -0,0 +1,43 @@
+#require 'shoes/framework_adapters/swt_shoes/layout'
+
+module SwtShoes
+# flow takes these options
+# :margin - integer - add this many pixels to all 4 sides of the layout
+ module Shoes
+
+ class Flow < Layout
+
+ # container - holds the widgets and controls painting
+ # layout - directs the container on _where_ to place widgets
+ attr_reader :container, :layout
+
+ def initialize composite_parent, opts = {}, &blk
+ @container = Swt::Widgets::Composite.new(composite_parent, Swt::SWT::NONE)
+
+ # RowLayout is horizontal by default, wrapping by default
+ @layout = Swt::Layout::RowLayout.new
+
+ # set the margins
+ margin(opts[:margin]) if opts[:margin]
+
+ if opts['width'] && opts['height']
+ @container.setSize(opts['width'], opts['height'])
+ end
+
+ @container.setLayout(@layout)
+
+ instance_eval &blk if block_given?
+
+ @container.pack
+ end
+
+ # Add this many pixels to margins on layout
+ def margin(margin_pixels)
+ @layout.marginTop = margin_pixels
+ @layout.marginRight = margin_pixels
+ @layout.marginBottom = margin_pixels
+ @layout.marginLeft = margin_pixels
+ end
+ end
+ end
+end
diff --git a/lib/shoes/framework_adapters/swt_shoes/layout.rb b/lib/shoes/framework_adapters/swt_shoes/layout.rb
new file mode 100644
index 00000000..54c41622
--- /dev/null
+++ b/lib/shoes/framework_adapters/swt_shoes/layout.rb
@@ -0,0 +1,65 @@
+#require 'shoes/framework_adapters/swt_shoes/element_methods'
+
+module SwtShoes
+ module Shoes
+ class Layout
+
+ DEFAULT_WIDTH = 800
+ DEFAULT_HEIGHT = 600
+ DEFAULT_TITLE = "Shooes!"
+
+
+ include ElementMethods
+ include Log4jruby::LoggerForClass
+
+ # default initializer for calls to
+ # super() from descendant classes
+ def initialize(composite_parent, opts = {}, &blk)
+ @container = Swt::Widgets::Composite.new(composite_parent, Swt::SWT::NONE || Swt::SWT::BORDER)
+
+ width, height = opts['width'] || DEFAULT_WIDTH, opts['height'] || DEFAULT_HEIGHT
+
+ # RowLayout is horizontal by default, wrapping by default
+ @layout = Swt::Layout::RowLayout.new
+
+ @layout.type = opts['layout_type'] if opts['layout_type']
+
+ # set the margins
+ set_layout_margins(opts[:margin]) if opts[:margin]
+
+ if width && height
+ #@border = Swt::Widgets::Composite.new(composite_parent, Swt::SWT::BORDER)
+ #debugger
+ @container.setSize(width, height)
+ end
+
+ @container.setLayout(@layout)
+
+ instance_eval &blk if block_given?
+
+ @container.pack unless width && height
+
+ end
+
+ # Add this many pixels to margins on layout
+ def set_layout_margins(margin_pixels)
+ @layout.marginTop = margin_pixels
+ @layout.marginRight = margin_pixels
+ @layout.marginBottom = margin_pixels
+ @layout.marginLeft = margin_pixels
+ 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
+end
diff --git a/lib/shoes/framework_adapters/swt_shoes/shoes.rb b/lib/shoes/framework_adapters/swt_shoes/shoes.rb
new file mode 100644
index 00000000..7aa2628c
--- /dev/null
+++ b/lib/shoes/framework_adapters/swt_shoes/shoes.rb
@@ -0,0 +1,36 @@
+require 'java'
+
+require 'rubygems'
+require 'facets/hash'
+
+require 'swt'
+
+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("Shoooes!")
+
+require 'shoes/framework_adapters/swt_shoes/app'
+#require 'shoes/framework_adapters/swt_shoes/element_methods'
+require 'shoes/framework_adapters/swt_shoes/layout'
+#require 'shoes/framework_adapters/swt_shoes/native'
+require 'shoes/framework_adapters/swt_shoes/window'
+#require 'shoes/framework_adapters/swt_shoes/flow'
+#require 'shoes/framework_adapters/swt_shoes/button'
+#require 'shoes/framework_adapters/swt_shoes/animation'
+
+module Shoes
+
+ include Log4jruby::LoggerForClass
+
+ def self.app(opts={}, &blk)
+ Shoes::App.new(opts, &blk)
+ logger.debug "Exiting Shoes.app"
+ end
+
+end
+
+def window(*a, &b)
+ Shoes.app(*a, &b)
+end
diff --git a/lib/shoes/framework_adapters/swt_shoes/window.rb b/lib/shoes/framework_adapters/swt_shoes/window.rb
new file mode 100644
index 00000000..f542279a
--- /dev/null
+++ b/lib/shoes/framework_adapters/swt_shoes/window.rb
@@ -0,0 +1,38 @@
+
+#require 'shoes/framework_adapters/swt_shoes/layout'
+
+module SwtShoes
+ module Shoes
+ class Window < Layout
+
+ DEFAULT_WIDTH = 800
+ DEFAULT_HEIGHT = 600
+ DEFAULT_TITLE = "Shooes!"
+
+ attr_reader :container
+
+ def initialize(opts = {}, &blk)
+ opts.stringify_keys!
+ @elements = opts['elements']
+
+ @container = Swt::Widgets::Shell.new($display, Swt::SWT::CLOSE)
+
+ width, height = opts['width'] || DEFAULT_WIDTH, opts['height'] || DEFAULT_HEIGHT
+
+ @container.setSize(width, height)
+ @container.setText(opts['title'] || DEFAULT_TITLE)
+
+ if opts['on_close']
+ logger.debug "Shell #{@container.inspect} adding block #{blk.inspect}"
+ @container.addListener(Swt::SWT::Close, opts['on_close'])
+ end
+
+ instance_eval &blk if block_given?
+ #@container.pack
+
+ @container.open
+ end
+
+ end
+ end
+end
\ No newline at end of file
diff --git a/lib/shoes/framework_adapters/white_shoes.rb b/lib/shoes/framework_adapters/white_shoes.rb
new file mode 100644
index 00000000..df7c4c1b
--- /dev/null
+++ b/lib/shoes/framework_adapters/white_shoes.rb
@@ -0,0 +1,67 @@
+
+require 'shoes/framework_adapters/white_shoes/base'
+require 'shoes/framework_adapters/white_shoes/app'
+
+require 'rubygems'
+require 'facets/hash'
+
+module WhiteShoes
+ module Shoes
+ #
+ ## Adapts the BaseView methods specific for the framework
+ #class BaseNative < Base
+ # # Queues the block call, so that it is only gets executed in the main thread.
+ # def queue(&block)
+ # end
+ #
+ # # Adds a widget to the given container widget.
+ # def add_widget_to_container(widget, container_widget)
+ # end
+ #
+ # # Removes a widget from the given container widget.
+ # def remove_widget_from_container(widget, container_widget)
+ # end
+ #
+ # # Removes all children from the given container widget.
+ # def remove_all_children(container_widget)
+ # end
+ #
+ # # Sets the widget name for the given widget if given.
+ # def set_widget_name(widget, widget_name)
+ # end
+ #
+ # # Autoconnects signals handlers for the view. If +other_target+ is given
+ # # it is used instead of the view itself.
+ # def autoconnect_signals(view, other_target = nil)
+ # end
+ #
+ # # Connects the signal from the widget to the given receiver block.
+ # # The block is executed in the context of the receiver.
+ # def connect_declared_signal_block(widget, signal, receiver, block)
+ # end
+ #
+ # # Connects the signal from the widget to the given receiver method.
+ # def connect_declared_signal(widget, signal, receiver, method)
+ # end
+ #
+ # # Builds widgets from the given filename, using the proper builder.
+ # def build_widgets_from(filename)
+ # end
+ #
+ # # Registers widgets as attributes of the view class.
+ # def register_widgets
+ # end
+ #
+ # class << self
+ # # Returns the builder file extension to be used for this view class.
+ # def builder_file_extension
+ # end
+ # end
+ #end
+
+ ## Adapts the BaseViewHelper methods specific for the framework
+ #class BaseViewHelper
+ #end
+ end
+end
+
diff --git a/lib/shoes/framework_adapters/white_shoes/app.rb b/lib/shoes/framework_adapters/white_shoes/app.rb
new file mode 100644
index 00000000..3bd6f1b6
--- /dev/null
+++ b/lib/shoes/framework_adapters/white_shoes/app.rb
@@ -0,0 +1,27 @@
+module WhiteShoes
+ module Shoes
+ # Adapter Template for the BaseApp methods specific for the framework.
+ class App < Base
+
+ def initialize(opts={}, &blk)
+ super
+ end
+
+ # Runs the application, starting anything the framework needs.
+ def run
+ end
+
+ # Refreshes the GUI application, running just one event loop.
+ #
+ # This method is mostly useful when writing tests. It shouldn't be used
+ # in normal applications.
+ def refresh
+ end
+
+ # Exits the application, freeing any resources used by the framework.
+ def quit
+ end
+ end
+ end
+end
+
diff --git a/lib/shoes/framework_adapters/white_shoes/base.rb b/lib/shoes/framework_adapters/white_shoes/base.rb
new file mode 100644
index 00000000..7a9584fc
--- /dev/null
+++ b/lib/shoes/framework_adapters/white_shoes/base.rb
@@ -0,0 +1,11 @@
+module WhiteShoes
+ module Shoes
+ class Base
+ attr_accessor :adapted_object
+
+ def initialize(adapted_object)
+ self.adapted_object = adapted_object
+ end
+ end
+ end
+end
diff --git a/lib/shoes/framework_adapters/white_shoes/button.rb b/lib/shoes/framework_adapters/white_shoes/button.rb
new file mode 100644
index 00000000..0fa5256d
--- /dev/null
+++ b/lib/shoes/framework_adapters/white_shoes/button.rb
@@ -0,0 +1,10 @@
+module WhiteShoes
+ module Shoes
+ class Button
+ def initialize container, text, opts = {}, &blk
+
+ end
+ end
+
+ end
+end
diff --git a/lib/shoes/archive/elements/image.rb b/lib/shoes/image.rb
similarity index 100%
rename from lib/shoes/archive/elements/image.rb
rename to lib/shoes/image.rb
diff --git a/lib/shoes/layout.rb b/lib/shoes/layout.rb
index 89318474..f45ce216 100644
--- a/lib/shoes/layout.rb
+++ b/lib/shoes/layout.rb
@@ -1,68 +1,30 @@
+
module Shoes
class Layout
+ include Shoes::ElementMethods
- include Log4jruby::LoggerForClass
-
- # default initializer for calls to
- # super() from descendant classes
- def initialize(opts = {})
-
- end
-
- #def stack(opts={}, &blk)
- # tstack = Stack.new(opts)
- # layout(tstack, &blk)
- #end
-
- def flow(opts = {}, &blk)
- swt_flow = Shoes::Flow.new(container, opts, &blk)
- end
-
+ # Descendant classes should configure their own instance
+ # of Java Swing JPanel, which is exposed to the
+ # &blk as 'container'. The Layout's own 'container'
+ # is held as 'parent_container' for any future use of the Layout
+ # itself.
+ # super(parent_container) must be called *after* the Layout instance
+ # has setup its own @container
+ def initialize(parent_container, opts={}, &blk)
- def button(text, opts={}, &blk)
- button = Shoes::Button.new(container, text, opts, &blk)
- #@elements[button.to_s] = button
- #button
end
-
- def animate(fps = 10, &blk)
- anim = Shoes::Animation.new(fps, &blk)
- 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
+ #def flow(opts = {}, &blk)
+ # swt_flow = Shoes::Flow.new container, opts, &blk
#end
#
#
- #def layout(layer, &blk)
- # parent = @current_panel
- # @current_panel = layer.panel
- # instance_eval &blk
- # parent.add(@current_panel)
- # @current_panel = parent
+ #def button(text, opts={}, &blk)
+ # button = Shoes::Button.new(container, text, opts, &blk)
+ # #@elements[button.to_s] = button
+ # #button
#end
end
-end
\ No newline at end of file
+end
diff --git a/lib/shoes/native.rb b/lib/shoes/native.rb
index d29bdecb..00e47898 100644
--- a/lib/shoes/native.rb
+++ b/lib/shoes/native.rb
@@ -1,13 +1,20 @@
module Shoes
- class Native
- include Log4jruby::LoggerForClass
-
- attr_reader :native_widget, :container
-
- # default initializer for calls to
- # super(opts) from descendant classes
- def initialize(opts = {})
-
+ class Native < BaseObject
+
+ #TODO: make this attr_accessor :identifier ??
+ # Needs to be inheritable
+ #def identifier
+ # @identifier
+ #end
+
+ #TODO: make this attr_accessor :native_widget ??
+ # Needs to be inheritable
+ #def native_widget
+ # @native_widget
+ #end
+
+ def initialize(opts={})
+ @identifier = opts[:id]
end
# This is the position of the Element from the top
@@ -69,16 +76,15 @@ def toggle
# displace(left: a number, top: a number) » self
# Displacing an element moves it. But without changing the layout around it.
def displace(left, top)
- unless native_widget.isDisposed
- logger.debug "#{self.inspect} displace top:#{top} left:#{left}"
- native_widget.setLocation(bounds.x + left, bounds.y + top)
- end
+ @native_widget.setLocation(bounds.x + left, bounds.y + top)
+ #@swt_composite.pack
end
private
def bounds
- @bounds ||= native_widget.getBounds
+ @native_widget ||= @native_widget.getBounds
end
+
end
-end
+end
\ No newline at end of file
diff --git a/lib/shoes/runnable_block.rb b/lib/shoes/runnable_block.rb
index 71b244e2..3122f4d2 100644
--- a/lib/shoes/runnable_block.rb
+++ b/lib/shoes/runnable_block.rb
@@ -6,41 +6,51 @@ module Shoes
# to encapsulate some of the data-passing required in the Thread
# boundary inside .timerExec()
class RunnableBlock
- def initialize(ms_per_frame, block)
- @ms_per_frame = ms_per_frame
+ def initialize(this, block)
+ #@ms_per_frame = ms_per_frame
@frame = 1
+ @this = this
@block = block
end
- def init
- set_next_timer
- end
-
- def stop
- @stop = true
+ def actionPerformed(event)
+ run(@frame, &@block)
+ @frame += 1
end
- def start
- if @stop
- @stop = nil
- run
- end
+ def run frame, &blk
+ yield frame
end
+
+ #def init
+ # set_next_timer
+ #end
- def run
- # This extra call to timerExec is what keeps the "loop" running.
- # every execution of #run re-sets the timer for the next execution.
- # The timer for the next-loop is started here so that timing between
- # loops is not delayed by processing the loop code. Hopefully the
- # @block.call finishes in time!
- set_next_timer
+ #def stop
+ # @stop = true
+ #end
+ #
+ #def start
+ # if @stop
+ # @stop = nil
+ # run
+ # end
+ #end
- @block[@frame]
- @frame += 1
- end
- def set_next_timer
- Swt.display.timer_exec(@ms_per_frame, self) unless @stop
- end
+ #def run
+ # # This extra call to timerExec is what keeps the "loop" running.
+ # # every execution of #run re-sets the timer for the next execution.
+ # # The timer for the next-loop is started here so that timing between
+ # # loops is not delayed by processing the loop code. Hopefully the
+ # # @block.call finishes in time!
+ # set_next_timer
+ #
+ # @block[@frame]
+ # @frame += 1
+ #end
+ #def set_next_timer
+ # Swt.display.timer_exec(@ms_per_frame, self) unless @stop
+ #end
end
end
diff --git a/lib/shoes/stack.rb b/lib/shoes/stack.rb
index e99ed05d..30fbad9e 100644
--- a/lib/shoes/stack.rb
+++ b/lib/shoes/stack.rb
@@ -1,8 +1,19 @@
module Shoes
- class Stack
- include SwtConstants
-
- def initialize
- # To change this template use File | Settings | File Templates.
+class Stack < Native
+ 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
\ No newline at end of file
diff --git a/rspec b/rspec-swing
similarity index 87%
rename from rspec
rename to rspec-swing
index 890608f1..cf8f37cb 100755
--- a/rspec
+++ b/rspec-swing
@@ -1,4 +1,4 @@
-#!/usr/bin/env jruby --debug -J-XstartOnFirstThread
+#!/usr/bin/env jruby --1.9 --debug
#
# This file was generated by RubyGems.
#
@@ -17,3 +17,5 @@ end
gem 'rspec-core', version
load Gem.bin_path('rspec-core', 'rspec', version)
+
+exit 0
\ No newline at end of file
diff --git a/rspec-swt b/rspec-swt
new file mode 100755
index 00000000..17204e93
--- /dev/null
+++ b/rspec-swt
@@ -0,0 +1,21 @@
+#!/usr/bin/env jruby --1.9 --debug -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)
+
+exit 0
\ No newline at end of file
diff --git a/samples/simple-flow-wrap.rb b/samples/simple-flow-wrap.rb
new file mode 100644
index 00000000..8c134345
--- /dev/null
+++ b/samples/simple-flow-wrap.rb
@@ -0,0 +1,11 @@
+Shoes.app :width => 200 do
+ flow :margin => 12, :fill => red do
+ background red
+ # Set up three buttons
+ button "button 1"
+ button "button 2"
+ button "button 3"
+ button "button 4"
+ button "button 5"
+ end
+end
\ No newline at end of file
diff --git a/spec/framework_adapters/swing_shoes/app_spec.rb b/spec/framework_adapters/swing_shoes/app_spec.rb
new file mode 100644
index 00000000..96ba5bdd
--- /dev/null
+++ b/spec/framework_adapters/swing_shoes/app_spec.rb
@@ -0,0 +1,9 @@
+require "spec_helper"
+require "spec/framework_adapters/swing_shoes/spec_helper"
+
+describe SwingShoes::Shoes::App do
+
+ it_behaves_like "A WhiteShoes Shoes::App"
+
+
+end
\ No newline at end of file
diff --git a/spec/framework_adapters/swing_shoes/spec_helper.rb b/spec/framework_adapters/swing_shoes/spec_helper.rb
new file mode 100644
index 00000000..4b359684
--- /dev/null
+++ b/spec/framework_adapters/swing_shoes/spec_helper.rb
@@ -0,0 +1,4 @@
+#require "shoes/framework_adapters/swing_shoes/base"
+require "shoes/framework_adapters/swing_shoes"
+
+Dir["./spec/framework_adapters/white_shoes/shared_examples/**/*.rb"].each {|f| require f}
\ No newline at end of file
diff --git a/spec/framework_adapters/swt_shoes/app_spec.rb b/spec/framework_adapters/swt_shoes/app_spec.rb
new file mode 100644
index 00000000..563e57a2
--- /dev/null
+++ b/spec/framework_adapters/swt_shoes/app_spec.rb
@@ -0,0 +1,9 @@
+require "spec_helper"
+require "spec/framework_adapters/swt_shoes/spec_helper"
+
+describe SwtShoes::Shoes::App do
+
+ it_behaves_like "A WhiteShoes Shoes::App"
+
+
+end
\ No newline at end of file
diff --git a/spec/framework_adapters/swt_shoes/spec_helper.rb b/spec/framework_adapters/swt_shoes/spec_helper.rb
new file mode 100644
index 00000000..f44f5f09
--- /dev/null
+++ b/spec/framework_adapters/swt_shoes/spec_helper.rb
@@ -0,0 +1,5 @@
+
+require "shoes/framework_adapters/swt_shoes"
+#require "shoes/framework_adapters/swt_shoes/app"
+
+Dir["./spec/framework_adapters/white_shoes/shared_examples/**/*.rb"].each {|f| require f}
\ No newline at end of file
diff --git a/spec/framework_adapters/white_shoes/app_spec.rb b/spec/framework_adapters/white_shoes/app_spec.rb
new file mode 100644
index 00000000..bba3080f
--- /dev/null
+++ b/spec/framework_adapters/white_shoes/app_spec.rb
@@ -0,0 +1,9 @@
+require "spec_helper"
+require "spec/framework_adapters/white_shoes/spec_helper"
+
+describe WhiteShoes::Shoes::App do
+
+ it_behaves_like "A WhiteShoes Shoes::App"
+
+
+end
\ No newline at end of file
diff --git a/spec/framework_adapters/white_shoes/shared_examples/shared_shoes_app_spec.rb b/spec/framework_adapters/white_shoes/shared_examples/shared_shoes_app_spec.rb
new file mode 100644
index 00000000..cbc955f9
--- /dev/null
+++ b/spec/framework_adapters/white_shoes/shared_examples/shared_shoes_app_spec.rb
@@ -0,0 +1,17 @@
+
+shared_examples "A WhiteShoes Shoes::App" do
+ describe "initializer" do
+ it "should accept zero arity" do
+ expect {
+ described_class.new
+ }.not_to raise_exception
+ end
+
+ it "should accept opts and block" do
+ expect {
+ described_class.new('options' => true) { ; }
+ }.not_to raise_exception
+ end
+
+ end
+end
\ No newline at end of file
diff --git a/spec/framework_adapters/white_shoes/spec_helper.rb b/spec/framework_adapters/white_shoes/spec_helper.rb
new file mode 100644
index 00000000..dfddf1fa
--- /dev/null
+++ b/spec/framework_adapters/white_shoes/spec_helper.rb
@@ -0,0 +1,4 @@
+require "shoes/framework_adapters/white_shoes/base"
+require "shoes/framework_adapters/white_shoes/app"
+
+Dir["./spec/framework_adapters/white_shoes/shared_examples/**/*.rb"].each {|f| require f}
\ No newline at end of file
diff --git a/spec/shoes/configuration_spec.rb b/spec/shoes/configuration_spec.rb
new file mode 100644
index 00000000..601108e2
--- /dev/null
+++ b/spec/shoes/configuration_spec.rb
@@ -0,0 +1,11 @@
+require "spec_helper"
+
+require 'shoes/configuration'
+
+describe Shoes::Configuration do
+
+ it "should keep a framework" do
+ Shoes::Configuration.framework = 'abc'
+ Shoes::Configuration.framework.should == 'abc'
+ end
+end
\ No newline at end of file
diff --git a/spec/shoes/stack_spec.rb b/spec/shoes/stack_spec.rb
new file mode 100644
index 00000000..a9fe3446
--- /dev/null
+++ b/spec/shoes/stack_spec.rb
@@ -0,0 +1,36 @@
+require "spec_helper"
+
+describe Shoes::Stack do
+ let(:display) { SWT::Widgets::Display.getDefault }
+ let(:parent_container) { SWT::Widgets::Shell.new(display) }
+
+ it "should have a SWT Composite" do
+ flow = Shoes::Stack.new(parent_container)
+ flow.container.should be_a SWT::Layouts::Composite
+ end
+
+ it "should vertically stack 3 widgets" do
+ button1 = button2 = button3 = nil
+ Shoes::Stack.new(parent_container) do
+ button1 = button("Button1")
+ button2 = button("Button2")
+ button3 = button("Button3")
+ end
+ button1.left.should >= 0
+ button2.left.should >= button1.left + button1.width
+ end
+
+ it "should have a margin" do
+ button1 = nil
+ flow = Shoes::Stack.new(parent_container, :margin => 10) do
+ button1 = button("Button1")
+ end
+ button1.top.should == 10
+ button1.left.should == 10
+ end
+
+ after :all do
+ SWT::Widgets::Display.getDefault.dispose
+ end
+
+end
\ No newline at end of file
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 78dcc659..185fe131 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -3,11 +3,3 @@
require 'java'
require 'rspec'
-
-require 'shoes'
-
-require 'shoes/swt_constants'
-include SwtConstants
-
-require 'mock_helpers'
-include MockHelpers
\ No newline at end of file
diff --git a/shoooes b/swing-shoooes
similarity index 56%
rename from shoooes
rename to swing-shoooes
index 2c155375..5471dec4 100755
--- a/shoooes
+++ b/swing-shoooes
@@ -1,4 +1,4 @@
-#!/usr/bin/env jruby -J-XstartOnFirstThread
+#!/usr/bin/env jruby --1.9
require 'rubygems'
$:<< "lib"
@@ -7,4 +7,4 @@ require 'shoes'
require ARGV[0]
-exit 0
\ No newline at end of file
+#exit 0
\ No newline at end of file
diff --git a/shoooesd b/swing-shoooesd
similarity index 73%
rename from shoooesd
rename to swing-shoooesd
index 0ae8c93c..818277f6 100755
--- a/shoooesd
+++ b/swing-shoooesd
@@ -1,9 +1,11 @@
-#!/usr/bin/env jruby -J-XstartOnFirstThread --debug
+#!/usr/bin/env jruby --1.9 --debug
require 'rubygems'
require 'ruby-debug'
$:<< "lib"
+require "java"
+
ENV['log_level'] = 'debug'
require 'shoes'
@@ -12,4 +14,4 @@ require ARGV[0]
puts "Exiting ./shooesd. Have a good day!"
-exit 0
\ No newline at end of file
+#exit 0
\ No newline at end of file
diff --git a/swt-shoooes b/swt-shoooes
new file mode 100755
index 00000000..9b0c9d07
--- /dev/null
+++ b/swt-shoooes
@@ -0,0 +1,12 @@
+#!/usr/bin/env jruby --1.9 -J-XstartOnFirstThread
+require 'rubygems'
+
+$:<< "lib"
+
+require 'shoes'
+require 'shoes/configuration'
+Shoes.configuration.framework = 'swt_shoes'
+
+require ARGV[0]
+
+exit 0
\ No newline at end of file
diff --git a/swt-shoooesd b/swt-shoooesd
new file mode 100755
index 00000000..a29ab60b
--- /dev/null
+++ b/swt-shoooesd
@@ -0,0 +1,17 @@
+#!/usr/bin/env jruby --1.9 -J-XstartOnFirstThread --debug
+require 'rubygems'
+require 'ruby-debug'
+
+$:<< "lib"
+
+ENV['log_level'] = 'debug'
+
+require 'shoes'
+require 'shoes/configuration'
+Shoes.configuration.framework = 'swt_shoes'
+
+require ARGV[0]
+
+puts "Exiting ./shooesd. Have a good day!"
+
+exit 0
\ No newline at end of file
diff --git a/testing/swing/blank_window.rb b/testing/swing/blank_window.rb
new file mode 100644
index 00000000..d8178c60
--- /dev/null
+++ b/testing/swing/blank_window.rb
@@ -0,0 +1,54 @@
+require 'java'
+
+import javax.swing.JPanel
+import javax.swing.JFrame
+import java.awt.Dimension
+import java.awt.FlowLayout
+import java.awt.BorderLayout
+import javax.swing.BoxLayout
+
+DEFAULT_HEIGHT = 600
+DEFAULT_WIDTH = 800
+
+class BlankWindow
+def initialize(opts={}, &blk)
+frame = javax.swing.JFrame.new()
+frame.getContentPane().add(javax.swing.JLabel.new("Hello World"))
+frame.setDefaultCloseOperation(javax.swing.JFrame::EXIT_ON_CLOSE)
+frame.pack()
+frame.set_visible(true)
+
+ ##opts.stringify_keys!
+ #height = opts['height'] ||= DEFAULT_HEIGHT
+ #width = opts['width'] ||= DEFAULT_WIDTH
+ #
+ #@elements = {}
+ #@frame = JFrame.new()
+ #
+ #@container = @frame.get_content_pane
+ #
+ #@layout = FlowLayout.new(FlowLayout::LEFT)
+ ##@layout.alignment = FlowLayout::LEFT
+ #@frame.setLayout(@layout)
+ #
+ ##flow(opts, &blk)
+ ##instance_eval &blk
+ #
+ #@frame.setDefaultCloseOperation(JFrame::EXIT_ON_CLOSE)
+ ##@container.border = javax.swing.border.LineBorder.new(java.awt.Color::BLUE, 4, true)
+ #@container.setBackground(java.awt.Color::BLUE)
+ #
+ ##@frame.pack()
+ #if opts['pack']
+ # @frame.pack
+ #else
+ # @frame.setSize(Dimension.new(opts['width'], opts['height']))
+ # @container.setSize(Dimension.new(opts['width'], opts['height']))
+ #end
+ #@frame.set_visible(true)
+end
+end
+
+BlankWindow.new { }
+
+#debugger; 1
\ No newline at end of file