[macruby-changes] [495] MacRuby/trunk/sample-macruby/HotCocoa

source_changes at macosforge.org source_changes at macosforge.org
Wed Aug 27 13:15:39 PDT 2008


Revision: 495
          http://trac.macosforge.org/projects/ruby/changeset/495
Author:   rich at infoether.com
Date:     2008-08-27 13:15:39 -0700 (Wed, 27 Aug 2008)
Log Message:
-----------
these are consolidated into the demo app

Modified Paths:
--------------
    MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/application.rb

Removed Paths:
-------------
    MacRuby/trunk/sample-macruby/HotCocoa/font.rb
    MacRuby/trunk/sample-macruby/HotCocoa/label.rb

Modified: MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/application.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/application.rb	2008-08-27 14:58:57 UTC (rev 494)
+++ MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/application.rb	2008-08-27 20:15:39 UTC (rev 495)
@@ -21,12 +21,16 @@
   attr_reader :current_demo_view, :main_window
   
   def start
-    load_view_files
+    load_demo_files
     application(:name => "Demo") do |app|
       app.delegate = self
+
+      # window example
       @main_window = window(:frame => [100, 100, 500, 500], :title => "HotCocoa Demo Application") do |win|
         win << window_geometry_label
         win << segment_control
+
+        # can hook events on the window (mapped via delegate)
         win.will_close { exit }
         win.did_move { update_window_geometry_label }
         win.did_resize { update_window_geometry_label }
@@ -61,30 +65,11 @@
   
   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
-      main_window << @current_demo_view
-    end
-
     def segment_control
       @segment_control ||= create_segment_control
     end
     
-    def create_window_geometry_label
-      label(:text => "", :layout => {:expand => :width, :start => false})
-    end
-  
+    # segmented control example
     def create_segment_control
       segmented_control(:layout => {:expand => :width, :align => :center, :start => false}, :segments => demo_app_segments) do |seg|
         seg.on_action do
@@ -97,7 +82,28 @@
       DemoApplication.view_classes.collect {|view_class| {:label => view_class.description, :width => 0}}
     end
       
-    def load_view_files
+    def window_geometry_label
+      @window_geometry_label ||= create_window_geometry_label
+    end
+  
+    # label example with custom font
+    def create_window_geometry_label
+      label(:text => "", :layout => {:expand => :width, :start => false}, :font => font(:system => 15))
+    end
+    
+    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 demo(description)
+      main_window.view.remove(current_demo_view) if current_demo_view
+      @current_demo_view = DemoApplication.view_with_description(description).create
+      main_window << @current_demo_view
+    end
+
+    def load_demo_files
       Dir.glob(File.join(File.dirname(__FILE__), 'views', '*.rb')).each do |file|
         load file
       end

Deleted: MacRuby/trunk/sample-macruby/HotCocoa/font.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/font.rb	2008-08-27 14:58:57 UTC (rev 494)
+++ MacRuby/trunk/sample-macruby/HotCocoa/font.rb	2008-08-27 20:15:39 UTC (rev 495)
@@ -1,14 +0,0 @@
-require 'hotcocoa'
-
-include HotCocoa
-
-application :name => "Font" 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

Deleted: MacRuby/trunk/sample-macruby/HotCocoa/label.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/label.rb	2008-08-27 14:58:57 UTC (rev 494)
+++ MacRuby/trunk/sample-macruby/HotCocoa/label.rb	2008-08-27 20:15:39 UTC (rev 495)
@@ -1,10 +0,0 @@
-require 'hotcocoa'
-
-include HotCocoa
-
-application :name => "Label" 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
-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080827/2c166fbc/attachment.html 


More information about the macruby-changes mailing list