Permalink
Browse files

Up to speed for demo

  • Loading branch information...
lancecarlson committed Aug 17, 2008
1 parent da03e0c commit d490a846fafc1f96f5ed0213e19b345d54f1fc85
@@ -6,9 +6,7 @@ class Window
attr_accessor :title
def initialize(name)
- @real_object = ::Qt::Label.new("Test", nil)
- @real_object.resize(150, 30)
- @real_object.show
+ @real_object = ::Qt::Label.new("Hello World!", nil)
end
def title=(title)
@@ -22,6 +20,10 @@ def text=(text)
@real_object.setText(text)
end
+ def show
+ @real_object.show
+ end
+
def method_missing(method, *args)
@real_object.send(method, *args)
end
@@ -7,12 +7,13 @@ module GUI
class << self
def window(name, options = {}, &block)
window = Window.new name
- window.instance_eval { block } if block
+ yield window if block_given?
end
def dsl(code_string)
self.instance_eval(code_string) if code_string
end
+
end
end
end
@@ -6,6 +6,7 @@ class Window
def initialize(name)
@toolkit = Toolkit
@name = name
+ @properties = {}
@toolkit_object = create
puts "#{@toolkit_object.inspect} Created"
end
@@ -15,20 +16,22 @@ def create
end
def title=(title)
- @properties[:title] = title
+ # @properties[:title] = title
@toolkit_object.title=(title)
end
- def size=(width, height)
- puts "size"
- @properties[:size] = { :width => width, :height => height }
- @toolkit_object.size = width, height
+ def size=(width=640, height=480)
+ if width.is_a?(Array)
+ height = width[1]
+ width = width[0]
+ end
+
+ # @properties[:size] = { :width => width, :height => height }
+ @toolkit_object.resize(width, height)
end
def method_missing(method, *args)
- puts "test"
- puts "#{method}"
- @properties[method] = *args
+ # @properties[method] = *args
@toolkit_object.send(method, *args)
end
@@ -2,15 +2,20 @@
describe "The DSL for" do
before do
+ @window = mock(Anvil::GUI::Window)
Anvil::GUI::Toolkit.register!("Fox")
- Anvil::GUI::Fox::Window.should_receive(:new).with(:test_window)
+ Anvil::GUI::Fox::Window.should_receive(:new).with(:test_window).and_return(@window)
end
describe Anvil::GUI, "window" do
it "should be friggin cool" do
- Anvil::GUI.window :test_window do
- title = "Hello World"
- size = 300, 400
+ @window.should_receive(:title=).with("Hello World")
+ @window.should_receive(:resize).with(300, 400)
+ @window.should_receive(:show)
+ Anvil::GUI.window :test_window do |w|
+ w.title = "Hello World"
+ w.size = 300, 400
+ w.show
end
end
end
@@ -1,5 +1,5 @@
-window :hello_world do
- title = "Hello World"
- size = 300, 400
- text = "Hello World"
+window :hello_world do |w|
+ w.size = 400, 200
+ w.text = "Hello World!!!!"
+ w.show
end

0 comments on commit d490a84

Please sign in to comment.