[MacRuby-devel] NSImage issue?

2008-11-13 Thread pedro gutierrez

Hi everybody,

This is my first message to the mailing list, I am a newbie in Cocoa  
so please bear with me...


In my first serious MacRuby project,  I have subclassed  
NSTextFieldCell and I have redefined drawInteriorWithFrame with the  
following code:


def drawInteriorWithFrame( rect, inView:view )

icon = NSImage.imageNamed( "example" )

puts icon.methods.join( " " )
puts "icon is valid: #{icon.isValid} and has size #{icon.size}"

icon.drawInRect( rect, NSZeroRect, NSCompositeSourceOver, 1.0 )

end

(i.e: I am just trying to draw an icon)

Here is what I get from the console:

[Session started at 2008-11-13 09:01:01 +.]
gem __super_objc_send__ enum_for to_enum object_id __id__  
define_singleton_method public_method method display extend  
respond_to? public_send send __send__ instance_exec instance_eval  
__native__? tap is_a? kind_of? instance_of? instance_variable_defined?  
instance_variable_set instance_variable_get instance_variables  
public_methods private_methods protected_methods singleton_methods  
methods inspect to_s frozen? freeze untaint tainted? taint dup clone  
eql? !~ =~ === nil? != ! equal? == hash

icon is valid: true and has size #
/Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/Contents/ 
Resources/PlaylistCell.rb:26:in `drawInteriorWithFrame:inView:':  
undefined method `drawInRect' for # (NoMethodError)
	from /Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/ 
Contents/Resources/PlaylistCell.rb:15:in `drawWithFrame:inView:'
	from /Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/ 
Contents/Resources/PlaylistCell.rb:15:in `drawWithFrame:inView:'
	from /Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/ 
Contents/Resources/rb_main.rb:22:in `NSApplicationMain'
	from /Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/ 
Contents/Resources/rb_main.rb:22:in `'


Can anybody please give me a hint of what I am doing wrong? Shouldn't  
I expect my instance of NSImage to respond to :drawInRect?


And by the way,  thanks a lot for this sweet MacRuby project !!
Cheers,
Pedro.


___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] NSImage issue?

2008-11-13 Thread Brad Wilson
I think there's a problem with your method call. If you look at the  
cocoa doc is has a selector with the signature:

drawInRect:fromRect:operation:fraction.

To call that from MacRuby you'd want to do something like:
icon.drawInRect(rect, fromRect:NSZeroRect,  
operationNSCompositeSourceOver, fraction:1.0.


See the way the named arguments line up? That'll work for any cocoa  
call. There's some discussion on the MacRuby tutorial under "Sending  
Messages" at http://www.macruby.org/trac/wiki/MacRubyTutorial



Another tip I got from somebody on the list:
object.methods(true, true) will give you a list of all methods on an  
object, including objective-c methods. That might help in future if  
you're not sure what the method call should be.


Hope that helps.

Brad


On 13/11/2008, at 8:11 PM, pedro gutierrez wrote:


Hi everybody,

This is my first message to the mailing list, I am a newbie in Cocoa  
so please bear with me...


In my first serious MacRuby project,  I have subclassed  
NSTextFieldCell and I have redefined drawInteriorWithFrame with the  
following code:


def drawInteriorWithFrame( rect, inView:view )

icon = NSImage.imageNamed( "example" )

puts icon.methods.join( " " )
puts "icon is valid: #{icon.isValid} and has size #{icon.size}"

icon.drawInRect( rect, NSZeroRect, NSCompositeSourceOver, 1.0 )

end

(i.e: I am just trying to draw an icon)

Here is what I get from the console:

[Session started at 2008-11-13 09:01:01 +.]
gem __super_objc_send__ enum_for to_enum object_id __id__  
define_singleton_method public_method method display extend  
respond_to? public_send send __send__ instance_exec instance_eval  
__native__? tap is_a? kind_of? instance_of?  
instance_variable_defined? instance_variable_set  
instance_variable_get instance_variables public_methods  
private_methods protected_methods singleton_methods methods inspect  
to_s frozen? freeze untaint tainted? taint dup clone eql? !~ =~ ===  
nil? != ! equal? == hash

icon is valid: true and has size #
/Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/Contents/ 
Resources/PlaylistCell.rb:26:in `drawInteriorWithFrame:inView:':  
undefined method `drawInRect' for # (NoMethodError)
	from /Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/ 
Contents/Resources/PlaylistCell.rb:15:in `drawWithFrame:inView:'
	from /Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/ 
Contents/Resources/PlaylistCell.rb:15:in `drawWithFrame:inView:'
	from /Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/ 
Contents/Resources/rb_main.rb:22:in `NSApplicationMain'
	from /Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/ 
Contents/Resources/rb_main.rb:22:in `'


Can anybody please give me a hint of what I am doing wrong?  
Shouldn't I expect my instance of NSImage to respond to :drawInRect?


And by the way,  thanks a lot for this sweet MacRuby project !!
Cheers,
Pedro.


___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] NSImage issue?

2008-11-13 Thread Brad Wilson
Sorry few typos in there, the only one that really matters is that the  
method call should be:


icon.drawInRect(rect, fromRect:NSZeroRect,  
operation:NSCompositeSourceOver, fraction:1.0)


On 13/11/2008, at 9:09 PM, Brad Wilson wrote:

I think there's a problem with your method call. If you look at the  
cocoa doc is has a selector with the signature:

drawInRect:fromRect:operation:fraction.

To call that from MacRuby you'd want to do something like:
icon.drawInRect(rect, fromRect:NSZeroRect,  
operationNSCompositeSourceOver, fraction:1.0.


See the way the named arguments line up? That'll work for any cocoa  
call. There's some discussion on the MacRuby tutorial under "Sending  
Messages" at http://www.macruby.org/trac/wiki/MacRubyTutorial



Another tip I got from somebody on the list:
object.methods(true, true) will give you a list of all methods on an  
object, including objective-c methods. That might help in future if  
you're not sure what the method call should be.


Hope that helps.

Brad


On 13/11/2008, at 8:11 PM, pedro gutierrez wrote:


Hi everybody,

This is my first message to the mailing list, I am a newbie in  
Cocoa so please bear with me...


In my first serious MacRuby project,  I have subclassed  
NSTextFieldCell and I have redefined drawInteriorWithFrame with the  
following code:


def drawInteriorWithFrame( rect, inView:view )

icon = NSImage.imageNamed( "example" )

puts icon.methods.join( " " )
puts "icon is valid: #{icon.isValid} and has size #{icon.size}"

icon.drawInRect( rect, NSZeroRect, NSCompositeSourceOver, 1.0 )

end

(i.e: I am just trying to draw an icon)

Here is what I get from the console:

[Session started at 2008-11-13 09:01:01 +.]
gem __super_objc_send__ enum_for to_enum object_id __id__  
define_singleton_method public_method method display extend  
respond_to? public_send send __send__ instance_exec instance_eval  
__native__? tap is_a? kind_of? instance_of?  
instance_variable_defined? instance_variable_set  
instance_variable_get instance_variables public_methods  
private_methods protected_methods singleton_methods methods inspect  
to_s frozen? freeze untaint tainted? taint dup clone eql? !~ =~ ===  
nil? != ! equal? == hash

icon is valid: true and has size #
/Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/Contents/ 
Resources/PlaylistCell.rb:26:in `drawInteriorWithFrame:inView:':  
undefined method `drawInRect' for #  
(NoMethodError)
	from /Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/ 
Contents/Resources/PlaylistCell.rb:15:in `drawWithFrame:inView:'
	from /Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/ 
Contents/Resources/PlaylistCell.rb:15:in `drawWithFrame:inView:'
	from /Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/ 
Contents/Resources/rb_main.rb:22:in `NSApplicationMain'
	from /Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/ 
Contents/Resources/rb_main.rb:22:in `'


Can anybody please give me a hint of what I am doing wrong?  
Shouldn't I expect my instance of NSImage to respond to :drawInRect?


And by the way,  thanks a lot for this sweet MacRuby project !!
Cheers,
Pedro.


___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


[MacRuby-devel] [MacRuby] #161: `macgem install` fails for the "wirble" gem

2008-11-13 Thread MacRuby
#161: `macgem install` fails for the "wirble" gem
--+-
 Reporter:  [EMAIL PROTECTED]  |   Owner:  [EMAIL PROTECTED]
 Type:  defect|  Status:  new  
 Priority:  minor |   Milestone:   
Component:  MacRuby   |Keywords:   
--+-
 Not sure what the state of macgem is, and what is necessary to make a gem
 compatible with macruby as opposed to normal Ruby, but I was trying to get
 my normal irb working environment compatible with macirb, and I ran across
 this problem:

 {{{
 [Thu Nov 13 - 02:18:58] [elliottcable @ Geoffrey] [~/Code/] [ - ]
 -- sudo macgem install wirble
 Password:
 
/Library/Frameworks/MacRuby.framework/Versions/0.4/usr/lib/ruby/1.9.0/net/http.rb:576:
 [BUG] destination 0x7fff5fbfdaa0 isn't in the auto zone
 MacRuby version 0.4 (ruby 1.9.0 2008-06-03) [universal-darwin9.0, x86_64]

 -- stack frame 
  (0xc08120060): 0004
 0001 (0xc08120068): 
 0002 (0xc08120070): 0004
 0003 (0xc08120078): 
 0004 (0xc08120080): 80040a280
 0005 (0xc08120088): 8003508a0
 0006 (0xc08120090): 0004
 0007 (0xc08120098): 0004
 0008 (0xc081200a0): 
 0009 (0xc081200a8): 8003a02e0
 0010 (0xc081200b0): 8003508a0
 0011 (0xc081200b8): 80034f060
 0012 (0xc081200c0): 8004359c0
 0013 (0xc081200c8): 0004
 0014 (0xc081200d0): 0004
 0015 (0xc081200d8): 
 0016 (0xc081200e0): 8004359c0
 0017 (0xc081200e8): 800087c40
 0018 (0xc081200f0): 0004
 0019 (0xc081200f8): 0004
 0020 (0xc08120100): 
 0021 (0xc08120108): 0004
 0022 (0xc08120110): 800087c40
 0023 (0xc08120118): 80007b3c0
 0024 (0xc08120120): 8007bf160
 0025 (0xc08120128): 80007b600
 0026 (0xc08120130): 
 0027 (0xc08120138): 8007bf160
 0028 (0xc08120140): 800973400
 0029 (0xc08120148): 0004
 0030 (0xc08120150): 
 0031 (0xc08120158): 0004
 0032 (0xc08120160): 8003cd480
 0033 (0xc08120168): 80092a400
 0034 (0xc08120170): 0001
 0035 (0xc08120178): 0004
 0036 (0xc08120180): 0004
 0037 (0xc08120188): 
 0038 (0xc08120190): 8003c9800
 0039 (0xc08120198): 0004
 0040 (0xc081201a0): c0821fd08
 0041 (0xc081201a8): 8000aaca0
 0042 (0xc081201b0): 800499d60
 0043 (0xc081201b8): 0004
 0044 (0xc081201c0): 0004
 0045 (0xc081201c8): c08120188 (= 37)
 0046 (0xc081201d0): 800499d60
 0047 (0xc081201d8): 8000aaca0
 0048 (0xc081201e0): 80078ba40
 0049 (0xc081201e8): 0004
 0050 (0xc081201f0): 0004
 0051 (0xc081201f8): 0004
 0052 (0xc08120200): 
 0053 (0xc08120208): 0004
 0054 (0xc08120210): 8000aaca0
 0055 (0xc08120218): 80078ba40
 0056 (0xc08120220): 0004
 0057 (0xc08120228): 8000aaca0
 0058 (0xc08120230): 8003bdec0
 0059 (0xc08120238): 800496860
 0060 (0xc08120240): 0004
 0061 (0xc08120248): 0004
 0062 (0xc08120250): 
 0063 (0xc08120258): 0004
 0064 (0xc08120260): 800496860
 0065 (0xc08120268): 8003bbe00
 0066 (0xc08120270): 8003ae820
 0067 (0xc08120278): 
 0068 (0xc08120280): 0004
 0069 (0xc08120288): 0004
 0070 (0xc08120290): 0004
 0071 (0xc08120298): 
 0072 (0xc081202a0): 104ddefd0
 0073 (0xc081202a8): 8003aa3e0
 0074 (0xc081202b0): 0004
 0075 (0xc081202b8): 
 0076 (0xc081202c0): 0004
 0077 (0xc081202c8): 
 0078 (0xc081202d0): 0004
 0079 (0xc081202d8): 
 0080 (0xc081202e0): 800488aa0
 0081 (0xc081202e8): 
 0082 (0xc081202f0): 0004
 0083 (0xc081202f8): 
 0084 (0xc08120300): 800088060
 0085 (0xc08120308): 0004
 0086 (0xc08120310): c0821f918
 0087 (0xc08120318): 80032d9a0
 0088 (0xc08120320): 80046ecc0
 0089 (0xc08120328): 0004
 0090 (0xc08120330): c081202f8 (= 83)
 0091 (0xc08120338): 80046ecc0
 0092 (0xc08120340): 80032d9a0
 0093 (0xc08120348): 
 0094 (0xc08120350): 8b3c0
 0095 (0xc08120358): 0004
 0096 (0xc08120360): 0004
 0097 (0xc08120368): 0004
 0098 (0xc08120370): 0004
 0099 (0xc08120378): 
 0100 (0xc08120380): 800457c40
 0101 (0xc08120388): 8b3c0
 0102 (0xc08120390): 80049e920
 0103 (0xc08120398): 8004e8140
 0104 (0xc081203a0): 0004
 0105 (0xc081203a8): 0004
 0106 (0xc081203b0): 0004
 0107 (0xc081203b8): 
 0108 (0xc081203c0): 80049e920
 0109 (0xc081203c8): 8004e8140
 0110 (0xc081203d0): 0004
 0111 (0xc081203d8): 0004
 0112 (0xc081203e0): 0004
 0113 (0xc081203e8): 0004
 0114 (0xc081203f0): 
 0115 (0xc081203f8): 0004
 0116 (0xc08120400): 0004
 0117 (0xc08120408): c0821f678
 0118 (0xc08120410): 0004
 0119 (0xc08120418): 0004
 0120 (0xc08120420): 
 0121 (0xc08120428): 0004
 0122 (0xc08120430): 0004
 0123 (0xc08120438): 0004
 0124 (0xc08120440): 0004
 0125 (0xc08120448): 0004
 0126 (0xc08120450): 8003ab840
 0127 (

[MacRuby-devel] http/json/parser

2008-11-13 Thread Matt Aimonetti
Since I can't use mechanize, hpricot or nokogiri, what are my alternatives
to parse HTML/XML?

What about JSON?

Rich, I believe you showed me a twitter app you were working on, would you
mind sharing what libs you use?

Thanks,

-Matt
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] http/json/parser

2008-11-13 Thread Richard Kilmer

You can use NSXMLParser (its a SAX-style parser).

I mapped it into HotCocoa with xml_parser:

xml_parser(:file => "myfile.xml") do |parser|
   # set of Delegate blocks (see below)
end.parse

Delegate blocks:

on_start_document
on_end_document

on_start_element { | element, namespace_uri, qualified_name,  
attributes | ... }

on_end_element { | element, namespace_uri, qualified_name | ... }

on_start_mapping_prefix { | mapping_prefix, to_uri | ... }
on_end_mapping_prefix { | mapping_prefix | ... }

on_attribute_declaration { | attribute_name, element, type,  
default_value | ... }

on_cdata { | cdata | ... }
on_characters { | characters | ... }
on_comment { | comment | ... }
on_ignorable_whitespace { | whitespace | ... }

on_element_declaration { | element_name, model | ... }
on_external_entity_declaration { | entity_name, public_id, system_id  
| ... }

on_internal_entity_declaration { | entity_name, value | ... }
on_notation_declaration { | notation_name, data | ... }
on_processing_instruction { | processing_instruction, data | ... }
on_unparsed_entity_declaration { | entity_name, public_id, system_id,  
notation_name | ... }


resolve_external_entity_name { | external_entity_name, system_id | ... }

on_parse_error { | parse_error | ... }
on_validation_error { | validation_error | ... }

Best,

Rich

On Nov 13, 2008, at 12:54 PM, Matt Aimonetti wrote:

Since I can't use mechanize, hpricot or nokogiri, what are my  
alternatives to parse HTML/XML?


What about JSON?

Rich, I believe you showed me a twitter app you were working on,  
would you mind sharing what libs you use?


Thanks,

-Matt
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] NSImage issue?

2008-11-13 Thread pedro gutierrez

Hi Brad,
That worked! Many thanks for putting me in the right path and next  
time I will read the documentation twice!

Cheers,
Pedro.

On 13 Nov 2008, at 10:13, Brad Wilson wrote:

Sorry few typos in there, the only one that really matters is that  
the method call should be:


icon.drawInRect(rect, fromRect:NSZeroRect,  
operation:NSCompositeSourceOver, fraction:1.0)


On 13/11/2008, at 9:09 PM, Brad Wilson wrote:

I think there's a problem with your method call. If you look at the  
cocoa doc is has a selector with the signature:

drawInRect:fromRect:operation:fraction.

To call that from MacRuby you'd want to do something like:
icon.drawInRect(rect, fromRect:NSZeroRect,  
operationNSCompositeSourceOver, fraction:1.0.


See the way the named arguments line up? That'll work for any cocoa  
call. There's some discussion on the MacRuby tutorial under  
"Sending Messages" at http://www.macruby.org/trac/wiki/MacRubyTutorial



Another tip I got from somebody on the list:
object.methods(true, true) will give you a list of all methods on  
an object, including objective-c methods. That might help in future  
if you're not sure what the method call should be.


Hope that helps.

Brad


On 13/11/2008, at 8:11 PM, pedro gutierrez wrote:


Hi everybody,

This is my first message to the mailing list, I am a newbie in  
Cocoa so please bear with me...


In my first serious MacRuby project,  I have subclassed  
NSTextFieldCell and I have redefined drawInteriorWithFrame with  
the following code:


def drawInteriorWithFrame( rect, inView:view )

icon = NSImage.imageNamed( "example" )

puts icon.methods.join( " " )
puts "icon is valid: #{icon.isValid} and has size #{icon.size}"

icon.drawInRect( rect, NSZeroRect, NSCompositeSourceOver, 1.0 )

end

(i.e: I am just trying to draw an icon)

Here is what I get from the console:

[Session started at 2008-11-13 09:01:01 +.]
gem __super_objc_send__ enum_for to_enum object_id __id__  
define_singleton_method public_method method display extend  
respond_to? public_send send __send__ instance_exec instance_eval  
__native__? tap is_a? kind_of? instance_of?  
instance_variable_defined? instance_variable_set  
instance_variable_get instance_variables public_methods  
private_methods protected_methods singleton_methods methods  
inspect to_s frozen? freeze untaint tainted? taint dup clone eql? ! 
~ =~ === nil? != ! equal? == hash

icon is valid: true and has size #
/Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/ 
Contents/Resources/PlaylistCell.rb:26:in  
`drawInteriorWithFrame:inView:': undefined method `drawInRect' for  
# (NoMethodError)
	from /Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/ 
Contents/Resources/PlaylistCell.rb:15:in `drawWithFrame:inView:'
	from /Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/ 
Contents/Resources/PlaylistCell.rb:15:in `drawWithFrame:inView:'
	from /Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/ 
Contents/Resources/rb_main.rb:22:in `NSApplicationMain'
	from /Users/sicozu/Projects/iAmbient/build/Release/iAmbient.app/ 
Contents/Resources/rb_main.rb:22:in `'


Can anybody please give me a hint of what I am doing wrong?  
Shouldn't I expect my instance of NSImage to respond to :drawInRect?


And by the way,  thanks a lot for this sweet MacRuby project !!
Cheers,
Pedro.


___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel