= Building the User Interface = The next step in creating a Lisp version of the currency converter application is to construct the user interface. Apple's tutorial [http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/05View/chapter_5_section_1.html#//apple_ref/doc/uid/TP40000863-CH7-SW1 describes in detail] how to do this. = Apple's Tutorial = Apple's tutorial explains how to use !InterfaceBuilder to create the user interface, and how to use XCode to create project files and write Objective-C code. Our project uses Lisp instead of Objective-C, and does not use XCode project files, so you can skip the part of Apple's tutorial that explains how to use XCode. = Using !InterfaceBuilder to Create the UI = We'll begin by using Apple's !InterfaceBuilder application to create a nibfile. The nibfile contains archived versions of the Objective-C objects that define the application's user interface. When you launch an application, Mac OS X uses the archived objects in the nibfile to create the windows and menus you see on the screen. Start by locating Apple's !InterfaceBuilder application. If you installed Apple's Developer Tools, !InterfaceBuilder should be in the folder "/Developer/Applications/": [[Image(finder-win1.jpg)]] '''NOTE:''' If you have not installed Apple's Developer Tools, you should do that now. You will not be able to build the !CurrencyConverter example without them. The Developer Tools are distributed as an optional install with Mac OS X 10.5 ("Leopard"). Look for the "XCode Tools" package in the "Optional Installs" folder on the Mac OS 10.5 install disk. Once you have located !InterfaceBuilder, double-click to launch the application. !InterfaceBuilder presents a window you can use to choose a template for the nibfile you are going to create. [[Image(ibwin-leopard1.jpg)]] Click the "Application" icon and then click the "Choose" button to create an application nibfile. !InterfaceBuilder creates a new application nibfile, but doesn't immediately save it. The Objective C objects that represent the new application's interface appear in a new untitled window: [[Image(ibwin-leopard2.jpg)]] The intial window and menubar also appear on the screen. The new application's name appears in the menus as "!NewApplication". Save the new nibfile into the "currency-converter" folder that you created earlier (on this page). !InterfaceBuilder 3.0 gives you a choice of file formats when you save a new nibfile; use the "NIB 3.x" format—the "XIB 3.x" format works fine for editing your user interface, but will not work correctly if you try to use it in a working application. Give the new file the name "!CurrencyConverter.nib". '''NOTE:''' Most Objective-C application projects use a main nibfile called "!MainMenu.nib", and if you use XCode to create a new application project, it creates a nibfile with that name. Apple's !CurrencyConverter tutorial assumes that the name of the main nibfile is "!MainMenu.nib". So, why do we tell you to use a different name? OpenMCL has a main nibfile built into it, whose name is "!MainMenu.nib". Normally you don't see it, and don't even need to know that it exists. But the OpenMCL application-building tools create a new application by copying resources from the OpenMCL application, so that your new application has available to it all the built-in OpenMCL tools. We ask you to name your nibfile "!CurrencyConverter.nib" so that it can coexist with the OpenMCL main nibfile without causing any problems. This difference between a Lisp project and an Objective-C project might be a little confusing at first. Just try to keep in mind that whenever Apple's tutorial refers to the "!MainMenu.nib" file, it means the file we have just created and named "!CurrencyConverter.nib". In an OpenMCL project, "!MainMenu.nib" is the name of the main Lisp nibfile, not your application's main nibfile. Because the Lisp application uses a standard nibfile, we can use Apple's instructions on how to use !InterfaceBuilder to create our user interface. Once the interface is created, we'll use Lisp code instead of Objective-C code to turn it into a working application, but our choice of programming language has no effect on how we create the User Interface. Skip straight to the part of Apple's tutorial called [http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/05View/chapter_5_section_1.html#//apple_ref/doc/uid/TP40000863-CH7-SW1 Defining the View: Building the User Interface]. Read the introduction to nibfiles, and follow the instructions to create the Currency Converter interface. (Remember that when the tutorial tells you to open and edit "!MainMenu.nib", you will instead open and edit your "!CurrencyConverter.nib".) When you reach the end of the section called [http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/05View/chapter_5_section_5.html#//apple_ref/doc/uid/TP40000863-CH7-DontLinkElementID_38 Test the Interface], and move on to the short section afterward called [http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/05View/chapter_5_section_6.html#//apple_ref/doc/uid/TP40000863-CH7-DontLinkElementID_39 What's Next], you are done creating the interface for your application. Save your nibfile and continue with the next section of this HOWTO. = What if You Need to Use !InterfaceBuilder 2.x? = If you are still using !InterfaceBuilder 2.x, the version shipped with Mac OS X 10.4.x ("Tiger"), you can still create a working nibfile and you can still follow the instructions in this HOWTO to create a Cocoa application with OpenMCL. The main obstacle is that the earlier versions of !InterfaceBuilder have a significantly different user interface, and so you may find it hard to follow Apple's tutorial when working with !InterfaceBuilder. If you are working with Mac OS X 10.4.x ("Tiger"), you can look [AppleCurrencyConverterBuildingUserInterfaceWithTiger here] to find a description of how to build the user interface files with the earlier version of !InterfaceBuilder. When you have finished building your user interface, you can continue with the section [AppleCurrencyConverterCreatingaLispFile "Creating a Lisp File"]. [AppleCurrencyConverter Start] [AppleCurrencyConverterMakingaProject Previous] [AppleCurrencyConverterAddingCustomClassesToTheNib Next]