[macruby-changes] [377] MacRuby/trunk/sample-macruby/HotCocoa/collection_view.rb

source_changes at macosforge.org source_changes at macosforge.org
Tue Jul 15 08:08:32 PDT 2008


Revision: 377
          http://trac.macosforge.org/projects/ruby/changeset/377
Author:   rich at infoether.com
Date:     2008-07-15 08:08:29 -0700 (Tue, 15 Jul 2008)
Log Message:
-----------
use new array controller mapping

Modified Paths:
--------------
    MacRuby/trunk/sample-macruby/HotCocoa/collection_view.rb

Modified: MacRuby/trunk/sample-macruby/HotCocoa/collection_view.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/collection_view.rb	2008-07-15 05:26:15 UTC (rev 376)
+++ MacRuby/trunk/sample-macruby/HotCocoa/collection_view.rb	2008-07-15 15:08:29 UTC (rev 377)
@@ -38,22 +38,21 @@
   
 end
 
-array_controller = NSArrayController.new
-array_controller.setAvoidsEmptySelection(false)
-array_controller.setPreservesSelection(false)
-array_controller.setSelectsInsertedObjects(false)
-array_controller.setAutomaticallyRearrangesObjects(true)
-array_controller.setSortDescriptors(NSArray.arrayWithObject(NSSortDescriptor.alloc.initWithKey("name", ascending: false)))
-array_controller.addObject Icon.new("Rich", image(:file => "rich.jpg"))
+icons = array_controller  :for => (1..100).collect { |i| Icon.new("Rich #{i}", image(:file => "rich.jpg")) },
+                          :avoids_empty_selection => true, 
+                          :preserves_selection => false, 
+                          :selects_inserted => false, 
+                          :rearrange_automatically => true, 
+                          :sort_by => {:name => :ascending}
 
 application do |app|
   window :frame => [100, 100, 500, 500], :title => "HotCocoa!" do |win|
-    win << scroll_view(:frame => [10,10,480,470]) do |scroll|
+    win << scroll_view(:frame => [10,10,480,470], :layout => {:expand => true, :other => :fill}) do |scroll|
       cv = collection_view :frame => [0,0,480,470], 
-                                       :content => {array_controller => "arrangedObjects"}, 
-                                       :selection_indexes => {array_controller => "selectionIndexes"},
-                                       :item_view => MyIconView.create,
-                                       :map_bindings => true
+                           :content => {icons => "arrangedObjects"}, 
+                           :selection_indexes => {icons => "selectionIndexes"},
+                           :item_view => MyIconView.create,
+                           :map_bindings => true
       scroll << cv
     end
   end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080715/0195d2be/attachment.html 


More information about the macruby-changes mailing list