Copyright ©1998 by AAA+ Software Forschungs- und Entwicklungs Ges.m.b.H.  All Rights Reserved.

4 Linking Joy into non-Joy Applications





This sections explains how you can link the Joy interpreter into your existing Objective-C or Java project.



Linking Joy to Draw.app

To show how Joy can be linked into an existing project, we will reuse the Draw.app example sources provided by Apple:
1. Copy the folder /System/Developer/Examples/AppKit/Draw into your home folder.

2. Double click the project file PB.project in your copy of the Draw sources.

3. In ProjectBuilder, select the Interfaces group. Double click the Draw.nib file.

4. In InterfaceBuilder, bring up the palettes panel. Select the Joy palette. If you have not loaded Joy.palette into InterfaceBuilder, refer to section 1 of this tutorial.
5. Drag a Joy interpreter object into the nib's document window.


Figure 1: Draw's main nib-File with a Joy interpreter added.

6. Double click the MainMenu icon in the nib's document window. Draw's main menu comes up.  Click on its Tools menu. Go back to the palettes panel and select the Menus palette. Drag a new menu item from the palette into the Tools menu and name it Joy.


Figure 2: Draw's main menu with a Joy menu item added to the Tools menu.

7. Ctrl-Drag a connection from the Joy menu item to the Interpreter icon in the nib's document window. Double click the showCommandWindow: action in the Connections inspector.
8. Save the nib-File.

9. Back in ProjectBuilder select the Frameworks group. Select the Add Files... item in the Project menu. In the open panel, select the files itkTcl.framework and joyRuntime.framework in the folder /Local/Library/Frameworks.

10. Select the Build & Run item in the Project Build submenu of ProjectBuilder's Tools menu. This will compile and link Draw.app and start it up with the the new Joy menu item.

You can now use Joy to:

Implement new modules of your project in Joy. Just add nib files containing an interpreter object and implement Joy code for that interpreter as shown in section 3 of this tutorial.
Modify your application at run-time by overwriting existing methods and adding new methods in the Joy command window.
Look into the run-time of your application by using the command window's built in application inspector. The next section shows how the application inspector can be used even for applications you do not have the source code for.