[macruby-changes] [315] MacRuby/trunk/sample-macruby
source_changes at macosforge.org
source_changes at macosforge.org
Mon Jul 7 18:21:12 PDT 2008
Revision: 315
http://trac.macosforge.org/projects/ruby/changeset/315
Author: rich at infoether.com
Date: 2008-07-07 18:21:12 -0700 (Mon, 07 Jul 2008)
Log Message:
-----------
added hotcocoa examples
Added Paths:
-----------
MacRuby/trunk/sample-macruby/HotCocoa/
MacRuby/trunk/sample-macruby/HotCocoa/box.rb
MacRuby/trunk/sample-macruby/HotCocoa/button.rb
MacRuby/trunk/sample-macruby/HotCocoa/combo_box.rb
MacRuby/trunk/sample-macruby/HotCocoa/font.rb
MacRuby/trunk/sample-macruby/HotCocoa/label.rb
MacRuby/trunk/sample-macruby/HotCocoa/movie_view.rb
MacRuby/trunk/sample-macruby/HotCocoa/popup_action.rb
MacRuby/trunk/sample-macruby/HotCocoa/rich.jpg
MacRuby/trunk/sample-macruby/HotCocoa/secure_text_field.rb
MacRuby/trunk/sample-macruby/HotCocoa/segmented_control.rb
MacRuby/trunk/sample-macruby/HotCocoa/table_view.rb
MacRuby/trunk/sample-macruby/HotCocoa/web_view.rb
Added: MacRuby/trunk/sample-macruby/HotCocoa/box.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/box.rb (rev 0)
+++ MacRuby/trunk/sample-macruby/HotCocoa/box.rb 2008-07-08 01:21:12 UTC (rev 315)
@@ -0,0 +1,21 @@
+$:.unshift "../lib"
+require 'hotcocoa'
+
+include HotCocoa
+
+application do |app|
+ window :frame => [200, 800, 300, 120], :title => "HotCocoa!" do |win|
+
+ win.did_move do
+ puts "Window moved to #{win.frame.inspect}!"
+ end
+
+ win.did_resize do
+ puts "Window resized to #{win.frame.size.inspect}"
+ end
+
+ win << box(:title => "I am a in a box!", :frame => [0,10, 300, 110], :auto_resize => [:width, :height]) do |b|
+ b << image_view(:frame => [10,10,60,60], :file => "rich.jpg")
+ end
+ end
+end
Added: MacRuby/trunk/sample-macruby/HotCocoa/button.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/button.rb (rev 0)
+++ MacRuby/trunk/sample-macruby/HotCocoa/button.rb 2008-07-08 01:21:12 UTC (rev 315)
@@ -0,0 +1,10 @@
+$:.unshift "../lib"
+require 'hotcocoa'
+
+include HotCocoa
+
+application do |app|
+ window :frame => [200, 200, 300, 120], :title => "HotCocoa!" do |win|
+ win << button(:title => "Push Me!", :on_action => Proc.new {puts "Ouch"})
+ end
+end
Added: MacRuby/trunk/sample-macruby/HotCocoa/combo_box.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/combo_box.rb (rev 0)
+++ MacRuby/trunk/sample-macruby/HotCocoa/combo_box.rb 2008-07-08 01:21:12 UTC (rev 315)
@@ -0,0 +1,22 @@
+$:.unshift "../lib"
+require 'hotcocoa'
+
+include HotCocoa
+
+class Person < Struct.new(:first, :last)
+ def to_str
+ "#{first} #{last}"
+ end
+end
+people = [
+ Person.new("Rich", "Kilmer"),
+ Person.new("Chad", "Fowler"),
+ Person.new("Tom", "Copeland")
+]
+
+application do |app|
+ window :frame => [100, 100, 500, 500], :title => "HotCocoa!" do |win|
+ win << combo_box(:frame => [10, 10, 100, 25], :data => people)
+ end
+end
+
Added: MacRuby/trunk/sample-macruby/HotCocoa/font.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/font.rb (rev 0)
+++ MacRuby/trunk/sample-macruby/HotCocoa/font.rb 2008-07-08 01:21:12 UTC (rev 315)
@@ -0,0 +1,15 @@
+$:.unshift "../lib"
+require 'hotcocoa'
+
+include HotCocoa
+
+application do |app|
+ window :frame => [200, 200, 300, 120], :title => "HotCocoa!" do |win|
+ win << box(
+ :title => "Very Big Font!",
+ :frame => [0,10, 300, 110],
+ :auto_resize => [:width, :height],
+ :title_font => font(:system => 30)
+ )
+ end
+end
\ No newline at end of file
Added: MacRuby/trunk/sample-macruby/HotCocoa/label.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/label.rb (rev 0)
+++ MacRuby/trunk/sample-macruby/HotCocoa/label.rb 2008-07-08 01:21:12 UTC (rev 315)
@@ -0,0 +1,11 @@
+$:.unshift "../lib"
+require 'hotcocoa'
+
+include HotCocoa
+
+application do |app|
+ window :frame => [100, 100, 300, 80], :title => "HotCocoa!" do |win|
+ win << label(:text => "This is a label", :font => font(:name => "Tahoma", :size => 40))
+ end
+end
+
Added: MacRuby/trunk/sample-macruby/HotCocoa/movie_view.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/movie_view.rb (rev 0)
+++ MacRuby/trunk/sample-macruby/HotCocoa/movie_view.rb 2008-07-08 01:21:12 UTC (rev 315)
@@ -0,0 +1,17 @@
+framework 'qtkit'
+
+$:.unshift "../lib"
+require 'hotcocoa'
+
+include HotCocoa
+
+application do |app|
+ window :frame => [100, 100, 500, 500], :title => "HotCocoa!" do |win|
+ mview = movie_view :frame => [10, 10, 480, 480],
+ :movie => movie(:file => "table_view.mov"),
+ :controller_buttons => [:back, :volume],
+ :fill_color => color(:name => :black)
+ win << mview
+ end
+end
+
Added: MacRuby/trunk/sample-macruby/HotCocoa/popup_action.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/popup_action.rb (rev 0)
+++ MacRuby/trunk/sample-macruby/HotCocoa/popup_action.rb 2008-07-08 01:21:12 UTC (rev 315)
@@ -0,0 +1,24 @@
+$:.unshift "../lib"
+require 'hotcocoa'
+
+include HotCocoa
+
+sounds = Dir.glob("/System/Library/Sounds/*.aiff")
+
+application do |app|
+ window :frame => [200, 200, 300, 120], :title => "HotCocoa!" do |win|
+ win << button(:frame => [10, 80, 100, 25], :title => "Sounds!") do |b|
+ b.on_action do
+ sound(:file => sounds[rand(sounds.size)]).play
+ end
+ end
+ win << popup(
+ :frame => [120, 80, 110, 25],
+ :title => "Push Me!",
+ :items => ["One", "Two", "Three"],
+ :on_action => Proc.new {|p| puts p.items.selected}
+ )
+ end
+end
+
+
Added: MacRuby/trunk/sample-macruby/HotCocoa/rich.jpg
===================================================================
(Binary files differ)
Property changes on: MacRuby/trunk/sample-macruby/HotCocoa/rich.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: MacRuby/trunk/sample-macruby/HotCocoa/secure_text_field.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/secure_text_field.rb (rev 0)
+++ MacRuby/trunk/sample-macruby/HotCocoa/secure_text_field.rb 2008-07-08 01:21:12 UTC (rev 315)
@@ -0,0 +1,10 @@
+$:.unshift "../lib"
+require 'hotcocoa'
+
+include HotCocoa
+
+application do |app|
+ window :frame => [200, 200, 300, 120], :title => "HotCocoa!" do |win|
+ win << secure_text_field(:echo => true, :frame => [20,20,200,20])
+ end
+end
Added: MacRuby/trunk/sample-macruby/HotCocoa/segmented_control.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/segmented_control.rb (rev 0)
+++ MacRuby/trunk/sample-macruby/HotCocoa/segmented_control.rb 2008-07-08 01:21:12 UTC (rev 315)
@@ -0,0 +1,22 @@
+$:.unshift "../lib"
+require 'hotcocoa'
+
+include HotCocoa
+
+application do |app|
+ window :frame => [200, 200, 500, 120], :title => "HotCocoa!" do |win|
+ segment = segmented_control(
+ :frame => [10,10,480,60],
+ :segments => [
+ {:label => "Richard", :width => 120},
+ {:label => "Laurent", :width => 120},
+ {:label => "Chad", :width => 120},
+ {:label => "Marcel", :width => 120}
+ ]
+ )
+ segment.on_action do
+ puts "Selected #{segment.selected_segment.label}"
+ end
+ win << segment
+ end
+end
Added: MacRuby/trunk/sample-macruby/HotCocoa/table_view.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/table_view.rb (rev 0)
+++ MacRuby/trunk/sample-macruby/HotCocoa/table_view.rb 2008-07-08 01:21:12 UTC (rev 315)
@@ -0,0 +1,25 @@
+$:.unshift "../lib"
+require 'hotcocoa'
+
+include HotCocoa
+
+application do |app|
+ window :frame => [100, 100, 500, 500], :title => "HotCocoa!" do |win|
+ people = table_view :frame => [10, 10, 480, 470],
+ :columns => [
+ column(:id => :first_name, :text => "First"),
+ column(:id => :last_name, :text => "Last")
+ ],
+ :data => [
+ {:first_name => "Richard", :last_name => "Kilmer"},
+ {:first_name => "Chad", :last_name => "Fowler"}
+ ]
+ win << split_view(:frame => [10, 10, 480, 470], :auto_resize => [:width, :height]) do |split|
+ split << scroll_view(:frame => [10,10,480,470]) do |scroll|
+ scroll << people
+ end
+ split << button(:title => "Test")
+ end
+ end
+end
+
Added: MacRuby/trunk/sample-macruby/HotCocoa/web_view.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/web_view.rb (rev 0)
+++ MacRuby/trunk/sample-macruby/HotCocoa/web_view.rb 2008-07-08 01:21:12 UTC (rev 315)
@@ -0,0 +1,14 @@
+framework 'webkit'
+
+$:.unshift "../lib"
+require 'hotcocoa'
+
+include HotCocoa
+
+application do |app|
+ window :frame => [100, 100, 500, 500], :title => "HotCocoa!" do |win|
+ web = web_view :frame => [10, 10, 480, 470], :url => "http://www.ruby-lang.org"
+ win << web
+ end
+end
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080707/28eae888/attachment-0001.html
More information about the macruby-changes
mailing list