[macruby-changes] [492] MacRuby/trunk/sample-macruby/HotCocoa/demo/lib
source_changes at macosforge.org
source_changes at macosforge.org
Wed Aug 27 07:57:01 PDT 2008
Revision: 492
http://trac.macosforge.org/projects/ruby/changeset/492
Author: rich at infoether.com
Date: 2008-08-27 07:57:01 -0700 (Wed, 27 Aug 2008)
Log Message:
-----------
add a few more examples
Modified Paths:
--------------
MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/application.rb
Added Paths:
-----------
MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/views/movie_view.rb
MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/views/table_view.rb
Modified: MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/application.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/application.rb 2008-08-27 06:10:58 UTC (rev 491)
+++ MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/application.rb 2008-08-27 14:57:01 UTC (rev 492)
@@ -25,9 +25,13 @@
application(:name => "Demo") do |app|
app.delegate = self
@main_window = window(:frame => [100, 100, 500, 500], :title => "HotCocoa Demo Application") do |win|
+ win << window_geometry_label
win << segment_control
win.will_close { exit }
+ win.did_move { update_window_geometry_label }
+ win.did_resize { update_window_geometry_label }
end
+ update_window_geometry_label
end
end
@@ -57,6 +61,16 @@
private
+ def update_window_geometry_label
+ frame = main_window.frame
+ window_geometry = "x=#{frame.origin.x}, y=#{frame.origin.y}, width=#{frame.size.width}, height=#{frame.size.height}"
+ window_geometry_label.text = "Window frame: (#{window_geometry})"
+ end
+
+ def window_geometry_label
+ @window_geometry_label ||= create_window_geometry_label
+ end
+
def demo(description)
main_window.view.remove(current_demo_view) if current_demo_view
@current_demo_view = DemoApplication.view_with_description(description).create
@@ -66,6 +80,10 @@
def segment_control
@segment_control ||= create_segment_control
end
+
+ def create_window_geometry_label
+ label(:text => "", :layout => {:expand => :width, :start => false})
+ end
def create_segment_control
segmented_control(:layout => {:expand => :width, :align => :center, :start => false}, :segments => demo_app_segments) do |seg|
Added: MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/views/movie_view.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/views/movie_view.rb (rev 0)
+++ MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/views/movie_view.rb 2008-08-27 14:57:01 UTC (rev 492)
@@ -0,0 +1,21 @@
+framework 'qtkit'
+
+class MovieView
+
+ def self.description
+ "Movie Views"
+ end
+
+ def self.create
+ layout_view :frame => [0, 0, 0, 0], :layout => {:expand => [:width, :height]}, :margin => 0, :spacing => 0 do |view|
+ mview = movie_view :layout => {:expand => [:width, :height]},
+ :movie => movie(:url => "http://movies.apple.com/movies/disney/wall-e/wall-e-tlr3_h.640.mov"),
+ :controller_buttons => [:back, :volume],
+ :fill_color => color(:name => :black)
+ view << mview
+ end
+ end
+
+ DemoApplication.register(self)
+
+end
\ No newline at end of file
Added: MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/views/table_view.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/views/table_view.rb (rev 0)
+++ MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/views/table_view.rb 2008-08-27 14:57:01 UTC (rev 492)
@@ -0,0 +1,26 @@
+class TableView
+
+ def self.description
+ "Table Views"
+ end
+
+ def self.create
+ layout_view :frame => [0, 0, 0, 0], :layout => {:expand => [:width, :height]}, :margin => 0, :spacing => 0 do |view|
+ view << scroll_view(:layout => {:expand => [:width, :height]}) do |scroll|
+ scroll << table_view(
+ :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"}
+ ]
+ )
+ end
+ end
+ end
+
+ DemoApplication.register(self)
+
+end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080827/bdcf43cc/attachment.html
More information about the macruby-changes
mailing list