[macruby-changes] [476] MacRuby/trunk/lib/hotcocoa/mappings/window.rb

source_changes at macosforge.org source_changes at macosforge.org
Sun Aug 24 19:02:55 PDT 2008


Revision: 476
          http://trac.macosforge.org/projects/ruby/changeset/476
Author:   rich at infoether.com
Date:     2008-08-24 19:02:54 -0700 (Sun, 24 Aug 2008)
Log Message:
-----------
enable size and centering of window

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

Modified: MacRuby/trunk/lib/hotcocoa/mappings/window.rb
===================================================================
--- 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), 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080824/9606db05/attachment-0001.html 


More information about the macruby-changes mailing list