[macruby-changes] [504] MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/views/controls.rb

source_changes at macosforge.org source_changes at macosforge.org
Wed Aug 27 22:21:56 PDT 2008


Revision: 504
          http://trac.macosforge.org/projects/ruby/changeset/504
Author:   rich at infoether.com
Date:     2008-08-27 22:21:56 -0700 (Wed, 27 Aug 2008)
Log Message:
-----------
add controls

Added Paths:
-----------
    MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/views/controls.rb

Added: MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/views/controls.rb
===================================================================
--- MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/views/controls.rb	                        (rev 0)
+++ MacRuby/trunk/sample-macruby/HotCocoa/demo/lib/views/controls.rb	2008-08-28 05:21:56 UTC (rev 504)
@@ -0,0 +1,69 @@
+class ControlsView
+
+  class Person < Struct.new(:first, :last)
+    def to_s
+      "#{first} #{last}"
+    end
+  end
+
+  def self.description 
+    "Other Controls" 
+  end
+  
+  def self.create
+    output_view = text_field_view
+    layout_view :frame => [0, 0, 0, 0], :layout => {:expand => [:width, :height]} do |view|
+      view << layout_view(:frame => [0, 0, 0, 40], :mode => :horizontal, :layout => {:expand => :width, :start => false}) do |hview|
+        hview << label(:text => "TextField", :frame => [0,0,100,25], :layout => {:start => false, :align => :center, :left_padding => 10})
+        hview << output_view
+      end
+      view << layout_view(:frame => [0, 0, 0, 40], :mode => :horizontal, :layout => {:expand => :width, :start => false}) do |hview|
+        hview << label(:text => "Combo Box", :frame => [0,0,100,25], :layout => {:start => false, :align => :center, :left_padding => 10})
+        hview << combox_box_view(output_view)
+      end
+      view << layout_view(:frame => [0, 0, 0, 40], :mode => :horizontal, :layout => {:expand => :width, :start => false}) do |hview|
+        hview << label(:text => "Popup", :frame => [0,0,100,25], :layout => {:start => false, :align => :center, :left_padding => 10})
+        hview << popup_view(output_view)
+      end
+      view << layout_view(:frame => [0, 0, 0, 40], :mode => :horizontal, :layout => {:expand => :width, :start => false}) do |hview|
+        hview << label(:text => "Secure TextField", :frame => [0,0,100,25], :layout => {:start => false, :align => :center, :left_padding => 10})
+        hview << secure_text_field_view
+      end
+    end
+  end
+  
+  def self.combox_box_view(output_view)
+    people = [
+      Person.new("Rich", "Kilmer"),
+      Person.new("Chad", "Fowler"),
+      Person.new("Tom", "Copeland")
+    ]
+    combo_box(
+      :frame => [0,0,300,25], 
+      :data => people, 
+      :layout => {:expand => :width, :start => true, :align => :center},
+      :on_action => Proc.new {|c| output_view.text = c.to_s}
+    )
+  end
+  
+  def self.popup_view(output_view)
+    popup(
+      :frame => [120, 80, 110, 25], 
+      :title => "Push Me!", 
+      :items => ["One", "Two", "Three"],
+      :layout => {:expand => :width, :start => true, :align => :center},
+      :on_action => Proc.new {|p| output_view.text = p.items.selected.to_s}
+    )
+  end
+  
+  def self.secure_text_field_view
+    secure_text_field(:echo => true, :frame => [20,20,200,25], :layout => {:expand => :width, :start => true, :align => :center})
+  end
+
+  def self.text_field_view
+    text_field(:frame => [20,20,200,25], :layout => {:expand => :width, :start => true, :align => :center})
+  end
+  
+  DemoApplication.register(self)
+  
+end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080827/9ef63a23/attachment-0001.html 


More information about the macruby-changes mailing list