[Rubycocoa-devel 955] Re: suggestion: dup method of NSPoint, NSSize, NSPoint and NSRange

Zurück zum Archiv-Index

Laurent Sansonetti lsans****@apple*****
Wed Jun 6 00:02:24 JST 2007


Hi Satoshi-san,

Good suggestion. I will add a general OSX::Boxed#dup method. All boxed  
structures inherit from OSX::Boxed.

Laurent

On Jun 5, 2007, at 7:30 AM, Satoshi Nakagawa wrote:

> Hi.
>
> Currently when I wrote some drawing code, I often want to dup  
> NSRect, NSSize and NSPoint.
>
> For example,
>
>  rect = NSRect.new(frame.origin, frame.size)
>  rect.origin.x += 10
>  'str'.drawInRect(rect)
>
> I want to write more smartly like,
>
>  rect = frame.dup
>
> But it causes an error: RuntimeError: Given structure 0x1510a44 has  
> null data.
>
> So I wrote an utility code:
>
> ----
> module OSX
>  class NSPoint
>    def dup; NSPoint.new(self.x, self.y); end
>  end
>
>  class NSSize
>    def dup; NSSize.new(self.width, self.height); end
>  end
>
>  class NSRect
>    def dup; NSRect.new(self.origin, self.size); end
>  end
>
>  class NSRange
>    def dup; NSRange.new(self.location, self.length); end
>  end
> end
> ----
>
> It's convenient for me.
> I think it's convenient for the other people.
>
> Could you add the code to RubyCocoa?
>
> --
> Satoshi Nakagawa
>
> _______________________________________________
> Rubycocoa-devel mailing list
> Rubyc****@lists*****
> http://lists.sourceforge.jp/mailman/listinfo/rubycocoa-devel




More information about the Rubycocoa-devel mailing list
Zurück zum Archiv-Index