Revision: 490 http://trac.macosforge.org/projects/ruby/changeset/490 Author: rich@infoether.com Date: 2008-08-26 23:10:40 -0700 (Tue, 26 Aug 2008) Log Message: ----------- working through what is needed by examples Modified Paths: -------------- MacRuby/trunk/lib/hotcocoa/layout_view.rb MacRuby/trunk/lib/hotcocoa/mappings/segmented_control.rb MacRuby/trunk/lib/hotcocoa/mappings/text_field.rb MacRuby/trunk/lib/hotcocoa/mappings/view.rb MacRuby/trunk/lib/hotcocoa/mappings/web_view.rb MacRuby/trunk/lib/hotcocoa/mappings/window.rb Added Paths: ----------- MacRuby/trunk/lib/hotcocoa/mappings/gradient.rb Modified: MacRuby/trunk/lib/hotcocoa/layout_view.rb =================================================================== --- MacRuby/trunk/lib/hotcocoa/layout_view.rb 2008-08-27 01:01:51 UTC (rev 489) +++ MacRuby/trunk/lib/hotcocoa/layout_view.rb 2008-08-27 06:10:40 UTC (rev 490) @@ -282,7 +282,12 @@ def <<(view) addSubview(view) end - + + def remove(subview, options = {}) + raise ArgumentError, "#{subview} is not a subview of #{self} and cannot be removed." unless subview.superview == self + options[:needs_display] == false ? subview.removeFromSuperviewWithoutNeedingDisplay : subview.removeFromSuperview + end + def addSubview(view) super if view.respond_to?(:layout) Added: MacRuby/trunk/lib/hotcocoa/mappings/gradient.rb =================================================================== --- MacRuby/trunk/lib/hotcocoa/mappings/gradient.rb (rev 0) +++ MacRuby/trunk/lib/hotcocoa/mappings/gradient.rb 2008-08-27 06:10:40 UTC (rev 490) @@ -0,0 +1,15 @@ +HotCocoa::Mappings.map :gradient => :NSGradient do + + def alloc_with_options(options) + if options[:colors] + if options[:locations] + NSGradient.alloc.initWithColors options.delete(:colors), atLocations:options.delete(:locations), colorSpace:(options.delete(:color_space) || NSColorSpace.deviceRGBColorSpace) + else + NSGradient.alloc.initWithColors() + end + elsif options[:start] && option[:end] + NSGradient.alloc.initWithStartingColor options.delete(:start), endingColor:options.delete(:end) + end + end + +end \ No newline at end of file Modified: MacRuby/trunk/lib/hotcocoa/mappings/segmented_control.rb =================================================================== --- MacRuby/trunk/lib/hotcocoa/mappings/segmented_control.rb 2008-08-27 01:01:51 UTC (rev 489) +++ MacRuby/trunk/lib/hotcocoa/mappings/segmented_control.rb 2008-08-27 06:10:40 UTC (rev 490) @@ -1,6 +1,6 @@ HotCocoa::Mappings.map :segmented_control => :NSSegmentedControl do - defaults :layout => {} + defaults :layout => {}, :frame => [0,0,0,0] def init_with_options(segmented_control, options) segmented_control.initWithFrame options.delete(:frame) Modified: MacRuby/trunk/lib/hotcocoa/mappings/text_field.rb =================================================================== --- MacRuby/trunk/lib/hotcocoa/mappings/text_field.rb 2008-08-27 01:01:51 UTC (rev 489) +++ MacRuby/trunk/lib/hotcocoa/mappings/text_field.rb 2008-08-27 06:10:40 UTC (rev 490) @@ -17,6 +17,10 @@ def text_align=(value) setAlignment(value) end + + def text_color=(value) + setTextColor(value) + end end Modified: MacRuby/trunk/lib/hotcocoa/mappings/view.rb =================================================================== --- MacRuby/trunk/lib/hotcocoa/mappings/view.rb 2008-08-27 01:01:51 UTC (rev 489) +++ MacRuby/trunk/lib/hotcocoa/mappings/view.rb 2008-08-27 06:10:40 UTC (rev 490) @@ -44,6 +44,11 @@ @layout end + def remove(subview, options = {}) + raise ArgumentError, "#{subview} is not a subview of #{self} and cannot be removed." unless subview.superview == self + options[:needs_display] == false ? subview.removeFromSuperviewWithoutNeedingDisplay : subview.removeFromSuperview + end + end end \ No newline at end of file Modified: MacRuby/trunk/lib/hotcocoa/mappings/web_view.rb =================================================================== --- MacRuby/trunk/lib/hotcocoa/mappings/web_view.rb 2008-08-27 01:01:51 UTC (rev 489) +++ MacRuby/trunk/lib/hotcocoa/mappings/web_view.rb 2008-08-27 06:10:40 UTC (rev 490) @@ -1,6 +1,6 @@ HotCocoa::Mappings.map :web_view => :WebView , :framework => :WebKit do - defaults :auto_size => true, :layout => {} + defaults :layout => {}, :frame => DefaultEmptyRect def init_with_options(web_view, options) web_view.initWithFrame(options.delete(:frame)) Modified: MacRuby/trunk/lib/hotcocoa/mappings/window.rb =================================================================== --- MacRuby/trunk/lib/hotcocoa/mappings/window.rb 2008-08-27 01:01:51 UTC (rev 489) +++ MacRuby/trunk/lib/hotcocoa/mappings/window.rb 2008-08-27 06:10:40 UTC (rev 490) @@ -14,7 +14,8 @@ :titled => NSTitledWindowMask, :closable => NSClosableWindowMask, :miniturizable => NSMiniaturizableWindowMask, - :resizable => NSResizableWindowMask + :resizable => NSResizableWindowMask, + :textured => NSTexturedBackgroundWindowMask } def init_with_options(window, options) @@ -62,6 +63,22 @@ orderFrontRegardless end + def background_color=(color) + setBackgroundColor(color) + end + + def background_color + backgroundColor + end + + def has_shadow? + hasShadow + end + + def has_shadow=(value) + setHasShadow(value) + end + end delegating "window:shouldDragDocumentWithEvent:from:withPasteboard:", :to => :should_drag_document?, :parameters => [:shouldDragDocumentWithEvent, :from, :withPasteboard]