-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8093ac
commit 3d6d098
Showing
104 changed files
with
913 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,4 @@ deps | |
dist | ||
pkg | ||
*.app | ||
docs-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module Shoes | ||
class Button < Native | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 'swt_shoes/app' | ||
#require 'swt_shoes/element_methods' | ||
require 'swt_shoes/layout' | ||
#require 'swt_shoes/native' | ||
require 'swt_shoes/window' | ||
#require 'swt_shoes/flow' | ||
#require 'swt_shoes/button' | ||
#require '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 |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | ||
|
||
describe "Basic Element Methods" do | ||
|
||
before(:all) do | ||
@gui = Shoes.app do | ||
|
||
|
||
button :text => "Change to Hello", :id => 'button_one' | ||
|
||
button :text => 'Change to Goodbye', :id => 'button_two' | ||
|
||
end | ||
end | ||
|
||
it "Should return 0 for left for button_one" do | ||
@gui.elements['button_one'].left.should be 0 | ||
end | ||
|
||
it "Should return 0 for top of button_one" do | ||
@gui.elements['button_one'].top.should be 0 | ||
end | ||
|
||
it "Should return 0 for left for button_two" do | ||
@gui.elements['button_two'].left.should be 0 | ||
end | ||
|
||
it "Should return 0 for top for button_two" do | ||
@gui.elements['button_two'].top.should be 147 | ||
end | ||
|
||
it "Should make button_one invisible when hide is called" do | ||
@gui.elements['button_one'].hide | ||
@gui.elements['button_one'].to_java.isVisible.should be false | ||
end | ||
|
||
it "Should make button_one visible when show is called" do | ||
@gui.elements['button_one'].hide | ||
@gui.elements['button_one'].show | ||
@gui.elements['button_one'].to_java.isVisible.should be true | ||
end | ||
|
||
it "Should make button_one hidden when toggle is called and it is visible" do | ||
@gui.elements['button_one'].show | ||
@gui.elements['button_one'].toggle | ||
@gui.elements['button_one'].to_java.isVisible.should be false | ||
end | ||
|
||
it "Should make button_one visible after being hidden when toggle is called and it is hidden" do | ||
@gui.elements['button_one'].hide | ||
@gui.elements['button_one'].toggle | ||
@gui.elements['button_one'].to_java.isVisible.should be true | ||
end | ||
|
||
|
||
after(:all) do | ||
@gui.frame.dispose() | ||
end | ||
|
||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require "spec_brown_helper" | ||
import javax.swing.JPanel | ||
import javax.swing.border.EmptyBorder | ||
|
||
describe Shoes::Flow do | ||
|
||
let(:parent_container) { JPanel.new } | ||
|
||
it "should have a container as JPanel" do | ||
flow = Shoes::Flow.new(parent_container) | ||
flow.parent_container.should == parent_container | ||
flow.container.should be_a JPanel | ||
flow.container.should_not === flow.parent_container | ||
end | ||
|
||
it "should horizontally stack 3 widgets" do | ||
button1 = button2 = button3 = nil | ||
tflow = Shoes::Flow.new(parent_container) do | ||
button1 = button("Button1") | ||
button2 = button("Button2") | ||
button3 = button("Button3") | ||
end | ||
debugger | ||
button1.left.should >= 0 | ||
button2.left.should > 0 | ||
button2.left.should >= button1.left + button1.width | ||
end | ||
|
||
it "should have a margin" do | ||
button1 = nil | ||
flow = Shoes::Flow.new(parent_container, :margin => 10) | ||
|
||
flow.container.border.should be_a EmptyBorder | ||
flow.container.border.border_insets.left.should == 10 | ||
end | ||
|
||
end |
File renamed without changes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require "spec_helper" | ||
|
||
describe Shoes::Native do | ||
|
||
it "should do something" do | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#require 'shoes/framework_adapters/swt_shoes/layout' | ||
|
||
module SwtShoes | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.