[macruby-changes] [847] MacRuby/trunk/lib/hotcocoa/mappings

source_changes at macosforge.org source_changes at macosforge.org
Fri Mar 6 21:26:10 PST 2009


Revision: 847
          http://trac.macosforge.org/projects/ruby/changeset/847
Author:   lsansonetti at apple.com
Date:     2009-03-06 21:26:09 -0800 (Fri, 06 Mar 2009)
Log Message:
-----------
adding NSProgressIndicator mapping + documentation comments for NSTextField and NSWindow (contributed by Matt Aimonetti)

Modified Paths:
--------------
    MacRuby/trunk/lib/hotcocoa/mappings/text_field.rb
    MacRuby/trunk/lib/hotcocoa/mappings/window.rb

Added Paths:
-----------
    MacRuby/trunk/lib/hotcocoa/mappings/progress_indicator.rb

Added: MacRuby/trunk/lib/hotcocoa/mappings/progress_indicator.rb
===================================================================
--- MacRuby/trunk/lib/hotcocoa/mappings/progress_indicator.rb	                        (rev 0)
+++ MacRuby/trunk/lib/hotcocoa/mappings/progress_indicator.rb	2009-03-07 05:26:09 UTC (rev 847)
@@ -0,0 +1,68 @@
+# Cocoa class: NSProgressIndicator
+# ================================
+# 
+# Apple Documentation: http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/ApplicationKit/Classes/NSProgressIndicator_Class/Reference/Reference.html
+#
+# Usage Example:
+# --------------
+#
+
+
+HotCocoa::Mappings.map :progress_indicator => :NSProgressIndicator do
+
+  defaults :layout => {}, :frame => [0,0,250,20]
+  
+  def init_with_options(progress_bar, options)
+    progress_bar.initWithFrame(options.delete(:frame))
+  end
+  
+  custom_methods do
+    
+    def to_f
+      doubleValue
+    end
+    alias :value :to_f
+    
+    def value=(value)
+      setDoubleValue(value.to_f)
+    end
+    
+    def start
+      startAnimation(nil)
+    end
+    
+    def stop
+      stopAnimation(nil)
+    end
+    
+    def show
+      setHidden(false)
+    end
+    
+    def hide
+      setHidden(true)
+    end
+    
+    def reset
+      setDoubleValue(0.0)
+    end
+    
+    def style=(style_name)
+      if style_name == :spinning
+        setStyle(NSProgressIndicatorSpinningStyle)
+      else
+        setStyle(NSProgressIndicatorBarStyle)
+      end
+    end
+    
+    def spinning_style
+      setStyle(NSProgressIndicatorSpinningStyle)
+    end
+    
+    def bar_style
+      setStyle(NSProgressIndicatorBarStyle)
+    end
+    
+  end
+  
+end
\ No newline at end of file


Property changes on: MacRuby/trunk/lib/hotcocoa/mappings/progress_indicator.rb
___________________________________________________________________
Added: svn:executable
   + *

Modified: MacRuby/trunk/lib/hotcocoa/mappings/text_field.rb
===================================================================
--- MacRuby/trunk/lib/hotcocoa/mappings/text_field.rb	2009-03-07 05:20:57 UTC (rev 846)
+++ MacRuby/trunk/lib/hotcocoa/mappings/text_field.rb	2009-03-07 05:26:09 UTC (rev 847)
@@ -1,3 +1,14 @@
+# NSTextField mappings
+# 
+# Usage example:
+#   @field = text_field(:text => "your text here", :layout => {:start => false}, :frame => [0, 0, 300, 300])
+#   @field.text = "New text"
+
+# Cocoa Documentation:
+#  http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTextField_Class/Reference/Reference.html
+#
+#
+
 HotCocoa::Mappings.map :text_field => :NSTextField do
 
   constant :text_align, {

Modified: MacRuby/trunk/lib/hotcocoa/mappings/window.rb
===================================================================
--- MacRuby/trunk/lib/hotcocoa/mappings/window.rb	2009-03-07 05:20:57 UTC (rev 846)
+++ MacRuby/trunk/lib/hotcocoa/mappings/window.rb	2009-03-07 05:26:09 UTC (rev 847)
@@ -1,3 +1,17 @@
+# Cocoa Reference: NSWindow
+#
+# Usage example:
+# ==============
+#
+#   window :frame => [100, 100, 604, 500], :title => "My app", :style => [:titled, :closable, :miniaturizable, :resizable] do |win|
+#     win.contentView.margin  = 0
+#     win.background_color    = color(:name => 'white')  
+#     win.will_close { exit }
+#   end
+#
+# Apple Developer Connection url: http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/Reference/Reference.html
+#
+
 HotCocoa::Mappings.map :window => :NSWindow do
     
   defaults  :style => [:titled, :closable, :miniaturizable, :resizable],
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090306/a3d6d15a/attachment.html>


More information about the macruby-changes mailing list