Page 1 of 1

Drawing in Objective Basic

PostPosted: Fri Feb 19, 2010 5:03 pm
by garethbaker
I've had a look at the documentation and can't seem to find any references to drawing (LineTo.. MoveTo.. BezierPath.. etc.). Are these available yet?

Thanks
Gareth

Re: Drawing in Objective Basic

PostPosted: Sun Feb 21, 2010 7:21 pm
by MaxClass
Bernd,

As asked by "garethbaker" is it possible to use calls to Core Graphics directly within Objective-Basic?

If so could you please post a few simple examples that would show the general syntax for accessing these methods. Once we know the proper syntax the rest should be quite easy.

Thank you in advance for your reply.

MaxClass

Re: Drawing in Objective Basic

PostPosted: Mon Feb 22, 2010 9:31 am
by berndnoetscher
garethbaker wrote:I've had a look at the documentation and can't seem to find any references to drawing (LineTo.. MoveTo.. BezierPath.. etc.). Are these available yet?

Thanks
Gareth


NSBezierPath and Co are not directly supported yet, but it is possible to do so by using "Declare" statements to extend the language features of Objective-Basic.
Check out the example "Objective-C", it shows how to directly use Cocoa.

You need a NSView and with a

Code: Select all
Event DrawRect(r As Rect)

  '  custom Objective-C calls with Declare

End Event



NSBezierPath and Co will be supported in future of course.

Re: Drawing in Objective Basic

PostPosted: Mon Feb 22, 2010 9:31 pm
by garethbaker
Thanks for the reply.

I've got a simple blue rectangle in a subclassed view!

One minor problem. Within the DrawRect Event this produces an error:

Dim colour As NSColor

If I do

Dim colour As NSColor = BlueColor

It works

The error is:
"Double expected"
Looking in the Objective-C code the declaration for the NSColor has - id colour = _NSCOLOR(NSCOLOR(0, 0, 0, 0));

Regards
Gareth

Re: Drawing in Objective Basic

PostPosted: Tue Feb 23, 2010 10:02 am
by berndnoetscher
Well done!

I tried to have the error message, you described, but I still don't get it.

Could you please post your code to me (bernd@kbasic.com) or the forum?
Thanks in advance.

Kind regards,
Bernd

Re: Drawing in Objective Basic

PostPosted: Wed Feb 24, 2010 9:58 am
by berndnoetscher
Gareth,

thanks for your help. I managed to find the small bug. It is fixed now and I uploaded a new version.

Kind regards,
Bernd