Revision
476
Author
rich@infoether.com
Date
2008-08-24 19:02:54 -0700 (Sun, 24 Aug 2008)

Log Message

enable size and centering of window

Modified Paths

Diff

Modified: MacRuby/trunk/lib/hotcocoa/mappings/window.rb (475 => 476)


--- MacRuby/trunk/lib/hotcocoa/mappings/window.rb	2008-08-24 20:51:32 UTC (rev 475)
+++ MacRuby/trunk/lib/hotcocoa/mappings/window.rb	2008-08-25 02:02:54 UTC (rev 476)
@@ -18,6 +18,15 @@
   }
 
   def init_with_options(window, options)
+    unless options[:frame]
+      size = (options.delete(:size) || [400,400])
+      width, height = size
+      screen_frame = NSScreen.screens[0].visibleFrame
+      center = options.delete(:center)
+      x = screen_frame.origin.x + (center ? (screen_frame.size.width - width)/2    : 30)
+      y = screen_frame.origin.y + (center ? (screen_frame.size.height - height)/2 : (screen_frame.size.height - height - 30))
+      options[:frame] = [x, y, width, height]
+    end
     window = window.initWithContentRect options.delete(:frame), 
                                styleMask:options.delete(:style), 
                                backing:options.delete(:backing),