Re: [MacRuby-devel] Quartz 2D Graphics problem

2012-10-21 Thread Robert Carl Rice
Hi Mark,

Unfortunately, I am not very familiar with objective C syntax. Is it easy to 
mix objective C statements with MacRuby?
For example, How would code the @context = 
NSGraphicsContext.currentContext.graphicsPort in objective C?

Thanks,
Bob Rice

On Oct 18, 2012, at 1:49 AM, Mark Rada  wrote:

> It seems as though the BridgeSupport definition of CGContextRef is missing. 
> At this point, I'm not sure where it should be coming from, documentation 
> indicates ApplicationServices.framework, but it's not in there.
> 
> On Mountain Lion, we have a similar problem with some CoreGraphics 
> definitions missing from the bridge support file it should be in. In that 
> case, it turned out that Apple has two CoreGraphics.frameworks and only one 
> shows up in the dependency chain. I did a quick ack through the 
> /System/Library/Frameworks and didn't see a definition for CGContextRef, so 
> I'm not sure if I missed it or if it is somewhere else now.
> 
> Bridge support on stuff that is changing seems to be a bit iffy on Mountain 
> Lion. The bridge support source used to be on macosforge.org, but Apple seems 
> to have taken it down (the bridge support developer left Apple and moved to 
> Belgium). The long term strategy will be to bring the bridge support stuff 
> into MacRuby itself; however, someone who has the source code will have to 
> post it somewhere for us first.
> 
> Sorry that I don't have better news; Objective-C for this segment might be 
> your only option. :(
> 
> --
>   Mark
> 
> 
> On 2012-10-18, at 12:30 AM, Robert Carl Rice  wrote:
> 
>> Hi,
>> 
>> I went back to working on an old project that uses core graphics and I'm 
>> having problems getting it to run again.
>> 
>> The following code gives me an error with the graphics context:
>> 
>>  def drawRect( rect )
>>  return unless @controller
>>  
>>  begin
>>  @context = NSGraphicsContext.currentContext.graphicsPort
>>  
>>  # Scale 15 min intervals to chart area
>>  @xscale = bounds.size.width / 25.0
>>  height = bounds.size.height
>>  @yscale = height / 2.0
>>  CGContextScaleCTM( @context, @xscale, @yscale )
>>  CGContextTranslateCTM( @context, 0.5, 0.5 ) # Indent 
>> from bounds
>>  
>>  # restore text size 
>>  CGContextSetTextMatrix( @context, 
>> CGAffineTransformMakeScale( 1 / @xscale, 1 / @yscale ))
>>  show_index( height )
>>  
>>  rescue => e
>>  ErrorLog.instance.rescue_error( e )
>>  end
>>  end
>> 
>> unrecognized runtime type `{CGContext=}'
>> /Users/robertrice/Library/Developer/Xcode/DerivedData/MacDriverLog-ebberjlfoqoqdzenjgqkdbkehuoj/Build/Products/Debug/MacDriverLog.app/Contents/Main_Window.bundle/Contents/Resources/RemarksIndexView.rb:55:in
>>  `drawRect'
>> /Users/robertrice/Library/Developer/Xcode/DerivedData/MacDriverLog-ebberjlfoqoqdzenjgqkdbkehuoj/Build/Products/Debug/MacDriverLog.app/Contents/Resources/rb_main.rb:69:in
>>  `'
>> 
>> line 55 is the first line:
>> @context = NSGraphicsContext.currentContext.graphicsPort
>> 
>> Has anything changed with regard to Quartz 2D drawing?
>> 
>> Thanks,
>> Bob Rice
>> 
>> ___
>> MacRuby-devel mailing list
>> [email protected]
>> http://lists.macosforge.org/mailman/listinfo/macruby-devel
> 
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo/macruby-devel

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


Re: [MacRuby-devel] Quartz 2D Graphics problem

2012-10-21 Thread Colin Thomas-Arnold
You can certainly compile a group of stuff as a framework, and add that 
framework to your project, but I've never tried to just toss in .h/.m files and 
access them from macruby.

Can anyone touch on that?  I'm interested to hear what can be done there...


AFA translating your code into Obj-C...


Here's the short version:

self.context = [[NSGraphics currentContext] graphicsPort];



And here's the long version!


// the header file, YourClass.h

@interface YourClass : ParentClass

@property (assign, nonatomic) CGContextRef context;
// or void* instead of CGContextRef, but graphicsPort returns a CGContextRef

@end



// the implementation file, YourClass.m

#import "YourClass.h"

@implementation YourClass

@synthesize context;

- drawRect:(CGRect)rect
{
  self.context = [[NSGraphics currentContext] graphicsPort];
}

@end




@colinta
colinta.com
github.com/colinta




On Oct 21, 2012, at 10:19 AM, Robert Carl Rice wrote:

> Hi Mark,
> 
> Unfortunately, I am not very familiar with objective C syntax. Is it easy to 
> mix objective C statements with MacRuby?
> For example, How would code the @context = 
> NSGraphicsContext.currentContext.graphicsPort in objective C?
> 
> Thanks,
> Bob Rice

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


Re: [MacRuby-devel] Quartz 2D Graphics problem

2012-10-21 Thread Mark Rada
Adding some Objective-C code could be done with a framework as suggested, or by 
creating a bundle. The bundle process is essentially the same as creating a C 
extension for Ruby. Any MacRuby project with a C extension could be used as an 
example:

https://github.com/pieter/macruby-bundle-example
https://github.com/Marketcircle/AXElements/tree/master/ext/accessibility/key_coder
https://github.com/alloy/ObjectiveBacon/tree/master/LanguageBindings/MacRuby/ext

You can then simply "require 'bundle'" the bundle file that is compiled.


On 2012-10-21, at 12:44 PM, Colin Thomas-Arnold  wrote:

> You can certainly compile a group of stuff as a framework, and add that 
> framework to your project, but I've never tried to just toss in .h/.m files 
> and access them from macruby.
> 
> Can anyone touch on that?  I'm interested to hear what can be done there...
> 
> 
> AFA translating your code into Obj-C...
> 
> 
> Here's the short version:
> 
> self.context = [[NSGraphics currentContext] graphicsPort];
> 
> 
> 
> And here's the long version!
> 
> 
> // the header file, YourClass.h
> 
> @interface YourClass : ParentClass
> 
> @property (assign, nonatomic) CGContextRef context;
> // or void* instead of CGContextRef, but graphicsPort returns a CGContextRef
> 
> @end
> 
> 
> 
> // the implementation file, YourClass.m
> 
> #import "YourClass.h"
> 
> @implementation YourClass
> 
> @synthesize context;
> 
> - drawRect:(CGRect)rect
> {
>   self.context = [[NSGraphics currentContext] graphicsPort];
> }
> 
> @end
> 
> 
> 
> 
> @colinta
> colinta.com
> github.com/colinta
> 
> 
> 
> 
> On Oct 21, 2012, at 10:19 AM, Robert Carl Rice wrote:
> 
>> Hi Mark,
>> 
>> Unfortunately, I am not very familiar with objective C syntax. Is it easy to 
>> mix objective C statements with MacRuby?
>> For example, How would code the @context = 
>> NSGraphicsContext.currentContext.graphicsPort in objective C?
>> 
>> Thanks,
>> Bob Rice
> 
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo/macruby-devel

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


Re: [MacRuby-devel] Quartz 2D Graphics problem

2012-10-21 Thread Jim Getzen
You don't need to make a framework or bundle to add Obj-C code to your project. 
I've been able to just add a .h/.m files directly to the project and call the 
Obj-C classes contained therein from my MacRuby code, just as if those classes 
were part of a framework.

What you can't do, of course, is call straight C functions or constants without 
a bridgesupport file.

Jim


On Oct 21, 2012, at 12:59 PM, Mark Rada  wrote:

Adding some Objective-C code could be done with a framework as suggested, or by 
creating a bundle. The bundle process is essentially the same as creating a C 
extension for Ruby. Any MacRuby project with a C extension could be used as an 
example:

https://github.com/pieter/macruby-bundle-example
https://github.com/Marketcircle/AXElements/tree/master/ext/accessibility/key_coder
https://github.com/alloy/ObjectiveBacon/tree/master/LanguageBindings/MacRuby/ext

You can then simply "require 'bundle'" the bundle file that is compiled.


On 2012-10-21, at 12:44 PM, Colin Thomas-Arnold  wrote:

> You can certainly compile a group of stuff as a framework, and add that 
> framework to your project, but I've never tried to just toss in .h/.m files 
> and access them from macruby.
> 
> Can anyone touch on that?  I'm interested to hear what can be done there...
> 
> 
> AFA translating your code into Obj-C...
> 
> 
> Here's the short version:
> 
> self.context = [[NSGraphics currentContext] graphicsPort];
> 
> 
> 
> And here's the long version!
> 
> 
> // the header file, YourClass.h
> 
> @interface YourClass : ParentClass
> 
> @property (assign, nonatomic) CGContextRef context;
> // or void* instead of CGContextRef, but graphicsPort returns a CGContextRef
> 
> @end
> 
> 
> 
> // the implementation file, YourClass.m
> 
> #import "YourClass.h"
> 
> @implementation YourClass
> 
> @synthesize context;
> 
> - drawRect:(CGRect)rect
> {
>   self.context = [[NSGraphics currentContext] graphicsPort];
> }
> 
> @end
> 
> 
> 
> 
> @colinta
> colinta.com
> github.com/colinta
> 
> 
> 
> 
> On Oct 21, 2012, at 10:19 AM, Robert Carl Rice wrote:
> 
>> Hi Mark,
>> 
>> Unfortunately, I am not very familiar with objective C syntax. Is it easy to 
>> mix objective C statements with MacRuby?
>> For example, How would code the @context = 
>> NSGraphicsContext.currentContext.graphicsPort in objective C?
>> 
>> Thanks,
>> Bob Rice
> 
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo/macruby-devel

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

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


Re: [MacRuby-devel] Quartz 2D Graphics problem

2012-10-21 Thread Robert Carl Rice
Hi,

Actually, I already have PBSerialPort m & h files by Paolo Bosetti dropped into 
my project and it works fine. I was wondering is a class could have both 
Objective C and Ruby code but from this discussion I gather the class must be 
either MacRuby or ObjC. Is this correct?

Thanks,
Bob Rice


On Oct 21, 2012, at 2:40 PM, Jim Getzen  wrote:

> You don't need to make a framework or bundle to add Obj-C code to your 
> project. I've been able to just add a .h/.m files directly to the project and 
> call the Obj-C classes contained therein from my MacRuby code, just as if 
> those classes were part of a framework.
> 
> What you can't do, of course, is call straight C functions or constants 
> without a bridgesupport file.
> 
> Jim
> 
> 
> On Oct 21, 2012, at 12:59 PM, Mark Rada  wrote:
> 
> Adding some Objective-C code could be done with a framework as suggested, or 
> by creating a bundle. The bundle process is essentially the same as creating 
> a C extension for Ruby. Any MacRuby project with a C extension could be used 
> as an example:
> 
> https://github.com/pieter/macruby-bundle-example
> https://github.com/Marketcircle/AXElements/tree/master/ext/accessibility/key_coder
> https://github.com/alloy/ObjectiveBacon/tree/master/LanguageBindings/MacRuby/ext
> 
> You can then simply "require 'bundle'" the bundle file that is compiled.
> 
> 
> On 2012-10-21, at 12:44 PM, Colin Thomas-Arnold  wrote:
> 
>> You can certainly compile a group of stuff as a framework, and add that 
>> framework to your project, but I've never tried to just toss in .h/.m files 
>> and access them from macruby.
>> 
>> Can anyone touch on that?  I'm interested to hear what can be done there...
>> 
>> 
>> AFA translating your code into Obj-C...
>> 
>> 
>> Here's the short version:
>> 
>> self.context = [[NSGraphics currentContext] graphicsPort];
>> 
>> 
>> 
>> And here's the long version!
>> 
>> 
>> // the header file, YourClass.h
>> 
>> @interface YourClass : ParentClass
>> 
>> @property (assign, nonatomic) CGContextRef context;
>> // or void* instead of CGContextRef, but graphicsPort returns a CGContextRef
>> 
>> @end
>> 
>> 
>> 
>> // the implementation file, YourClass.m
>> 
>> #import "YourClass.h"
>> 
>> @implementation YourClass
>> 
>> @synthesize context;
>> 
>> - drawRect:(CGRect)rect
>> {
>>   self.context = [[NSGraphics currentContext] graphicsPort];
>> }
>> 
>> @end
>> 
>> 
>> 
>> 
>> @colinta
>> colinta.com
>> github.com/colinta
>> 
>> 
>> 
>> 
>> On Oct 21, 2012, at 10:19 AM, Robert Carl Rice wrote:
>> 
>>> Hi Mark,
>>> 
>>> Unfortunately, I am not very familiar with objective C syntax. Is it easy 
>>> to mix objective C statements with MacRuby?
>>> For example, How would code the @context = 
>>> NSGraphicsContext.currentContext.graphicsPort in objective C?
>>> 
>>> Thanks,
>>> Bob Rice
>> 
>> ___
>> MacRuby-devel mailing list
>> [email protected]
>> http://lists.macosforge.org/mailman/listinfo/macruby-devel
> 
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo/macruby-devel
> 
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo/macruby-devel

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


Re: [MacRuby-devel] Quartz 2D Graphics problem

2012-10-21 Thread Colin Thomas-Arnold
yup, you can't mix and match within one file.


@colinta
colinta.com
github.com/colinta




On Oct 21, 2012, at 1:22 PM, Robert Carl Rice wrote:

> Hi,
> 
> Actually, I already have PBSerialPort m & h files by Paolo Bosetti dropped 
> into my project and it works fine. I was wondering is a class could have both 
> Objective C and Ruby code but from this discussion I gather the class must be 
> either MacRuby or ObjC. Is this correct?
> 
> Thanks,
> Bob Rice
> 
> 
> On Oct 21, 2012, at 2:40 PM, Jim Getzen  wrote:
> 
>> You don't need to make a framework or bundle to add Obj-C code to your 
>> project. I've been able to just add a .h/.m files directly to the project 
>> and call the Obj-C classes contained therein from my MacRuby code, just as 
>> if those classes were part of a framework.
>> 
>> What you can't do, of course, is call straight C functions or constants 
>> without a bridgesupport file.
>> 
>> Jim
>> 
>> 
>> On Oct 21, 2012, at 12:59 PM, Mark Rada  wrote:
>> 
>> Adding some Objective-C code could be done with a framework as suggested, or 
>> by creating a bundle. The bundle process is essentially the same as creating 
>> a C extension for Ruby. Any MacRuby project with a C extension could be used 
>> as an example:
>> 
>> https://github.com/pieter/macruby-bundle-example
>> https://github.com/Marketcircle/AXElements/tree/master/ext/accessibility/key_coder
>> https://github.com/alloy/ObjectiveBacon/tree/master/LanguageBindings/MacRuby/ext
>> 
>> You can then simply "require 'bundle'" the bundle file that is compiled.
>> 
>> 
>> On 2012-10-21, at 12:44 PM, Colin Thomas-Arnold  wrote:
>> 
>>> You can certainly compile a group of stuff as a framework, and add that 
>>> framework to your project, but I've never tried to just toss in .h/.m files 
>>> and access them from macruby.
>>> 
>>> Can anyone touch on that?  I'm interested to hear what can be done there...
>>> 
>>> 
>>> AFA translating your code into Obj-C...
>>> 
>>> 
>>> Here's the short version:
>>> 
>>> self.context = [[NSGraphics currentContext] graphicsPort];
>>> 
>>> 
>>> 
>>> And here's the long version!
>>> 
>>> 
>>> // the header file, YourClass.h
>>> 
>>> @interface YourClass : ParentClass
>>> 
>>> @property (assign, nonatomic) CGContextRef context;
>>> // or void* instead of CGContextRef, but graphicsPort returns a CGContextRef
>>> 
>>> @end
>>> 
>>> 
>>> 
>>> // the implementation file, YourClass.m
>>> 
>>> #import "YourClass.h"
>>> 
>>> @implementation YourClass
>>> 
>>> @synthesize context;
>>> 
>>> - drawRect:(CGRect)rect
>>> {
>>>   self.context = [[NSGraphics currentContext] graphicsPort];
>>> }
>>> 
>>> @end
>>> 
>>> 
>>> 
>>> 
>>> @colinta
>>> colinta.com
>>> github.com/colinta
>>> 
>>> 
>>> 
>>> 
>>> On Oct 21, 2012, at 10:19 AM, Robert Carl Rice wrote:
>>> 
 Hi Mark,
 
 Unfortunately, I am not very familiar with objective C syntax. Is it easy 
 to mix objective C statements with MacRuby?
 For example, How would code the @context = 
 NSGraphicsContext.currentContext.graphicsPort in objective C?
 
 Thanks,
 Bob Rice
>>> 
>>> ___
>>> MacRuby-devel mailing list
>>> [email protected]
>>> http://lists.macosforge.org/mailman/listinfo/macruby-devel
>> 
>> ___
>> MacRuby-devel mailing list
>> [email protected]
>> http://lists.macosforge.org/mailman/listinfo/macruby-devel
>> 
>> ___
>> MacRuby-devel mailing list
>> [email protected]
>> http://lists.macosforge.org/mailman/listinfo/macruby-devel
> 
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo/macruby-devel

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


[MacRuby-devel] GC warnings playing sound files

2012-10-21 Thread Robert Carl Rice
Hi,

I recently  added some NSSound alerts to one of my project. It works but it 
generates a "GC operation on unregistered thread" warning when I play the 
sound. Is there a way to avoid this warning?

Thanks,
Bob Rice

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


Re: [MacRuby-devel] GC warnings playing sound files

2012-10-21 Thread Mark Rada
Hi Rob,

That smells suspiciously like a GC bug on Apple's end of things; though it 
might be a bug in MacRuby. You could find out by writing the same code in 
Objective-C, then compile with GC and test it out.


On 2012-10-21, at 3:37 PM, Robert Carl Rice  wrote:

> Hi,
> 
> I recentlyadded some NSSound alerts to one of my project. It works but it 
> generates a "GC operation on unregistered thread" warning when I play the 
> sound. Is there a way to avoid this warning?
> 
> Thanks,
> Bob Rice
> 
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo/macruby-devel

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