Using the new Cocoa-Eiffel framework

by Daniel Furrer (modified: 2009 Jun 19)

I am busy working on the Vision2-Cocoa implementation and have some nice additions for better interaction with Objective-C ready, the code is now void-safe and the Cocoa-Eiffel wrapper is much more complete. But more about that some other time. For now I just want to take a short break and present you the "New Cocoa Application Wizard" which I wrote yesterday.
This new wizard is similar to those for creating a new EiffelVision2 or WEL projects and should get you started right away. This wizard and the current Cocoa-Eiffel library will be available in a development version of EiffelStudio soon after 6.4 is out and will hopefully make it in the official version 6.5.

Further down are a couple of screenshots where you can see the new wizard. Note that the wizard, written in EiffelVision2, is already running with the new Cocoa backend, while the EiffelStudio window you can see in the background is still using the GTK+ implementation.

If you are interested in writing a graphical application on Mac OS X using Eiffel make sure you give the new Cocoa-Eiffel framework a shot.

The code for creating an application with a single window is pretty easy: note description : "Root class for this application." author : "Generated by the New Cocoa Application Wizard." date : "$Date: 2009/6/19 13:26:18 $" revision : "1.0.0" class APPLICATION inherit EV_APPLICATION create make_and_launch feature {NONE} -- Initialization make_and_launch -- Initialize and launch application do make prepare launch end prepare -- Prepare the first window to be displayed. do -- create and initialize the main window. create main_window.make (create {NS_RECT}.make_rect (100, 100, 300, 300), {NS_WINDOW}.titled_window_mask | {NS_WINDOW}.closable_window_mask, False) -- set the title of the window. main_window.set_title (create {NS_STRING}.make_with_string ("My cocoa application")) -- Show the main window. main_window.make_key_and_order_front end feature {NONE} -- Implementation main_window: NS_WINDOW -- Main window. end -- class APPLICATION

1.0

Comments
  • Manu (8 years ago 19/6/2009)

    Very cool!!

    • Daniel Furrer (8 years ago 20/6/2009)

      thanks, on a side note...

      some icons on OS X should be available in a much higher resolution (and maybe even adapted to Apple's Human Interface Guidelines). How does the process of creating those icons work at Eiffel Software? I might know somebody who is interested in doing those icons.

      Here's a screenshot of the problem (wizard icon):

      • Manu (8 years ago 20/6/2009)

        We usually do them ourselves and for not being graphic designer to start with, it is usually pretty good. Currently EiffelStudio uses a 16x16 pixmap to set the title icon of a Window, although I guess it would be possible to provide a 32x32 pixmap, but then the 16x16 version would be interpreted from the 32x32 and might not be of such good quality.

        It is definitely something we should improve since various platforms may have a restriction on this icon.

  • Peter Gummer (8 years ago 20/6/2009)

    32x32 is not enough

    It still won't look good at 32x32.

    http://en.wikipedia.org/wiki/Apple_Icon_Image

    - Peter

  • Colin LeMahieu (8 years ago 18/7/2009)

    How does one get this program to compile. I made a basic vision2 application, set vision_implementation to cocoa and tried to compile it. It's exploding in the C compilation section with a bunch of errors that seem to indicate the compiler isn't set to compile objective-c. I'm on OSX leopard.

  • Daniel Furrer (8 years ago 21/7/2009)

    Please locate your config.sh file and add -ObjC in the line where ccflags is set.

    ccflags='-ObjC -pipe -no-cpp-precomp -fno-common -fPIC'

  • quenio (7 years ago 19/11/2009)

    Where is it?

    Hi,

    There is no link in this post.

    How can I get access to EiffelVision for Cocoa?

    Thanks,

      Quenio