Aug 97 - Getting Started
Volume Number: 13
Issue Number: 8
Column Tag: Getting Started
Getting Started: VerySimpleText, Version 1
by Dave Mark, ©1997, All Rights Reserved
In last month's column, we built our first few applications under the OPENSTEP
environment. We started off with a guided tour of OPENSTEP, including the File
Viewer, dock, menuing system, and terminal emulator. The applications were all
Objective-C console apps. None took advantage of the user interface elements that give
our OPENSTEP apps the OPENSTEP look-and-feel.
This month's column changes that with the introduction of VerySimpleText, our first
true OPENSTEP application. As its name implies, VerySimpleText is an OPENSTEP
version of the Mac's classic SimpleText application. Before you read on, think about
how you would go about building a SimpleText application. If you are a C programmer,
you would need to deal with menu and window management, fonts, printing, embedded
graphics (extremely primitive in SimpleText), and a host of other issues such as
QuickTime, clipboard, TextEdit, and memory management. If you are using PowerPlant
and C++, things get a bit simpler, since you can take advantage of PowerPlant's
pre-built classes.
The OPENSTEP tools ProjectBuilder and InterfaceBuilder take this approach one step
further by adding a RAD (stands for Rapid Application Development) front end to the
development process. ProjectBuilder is somewhat like the CodeWarrior IDE, but is
tightly integrated with Interface Builder. Interface Builder allows you to create and
arrange the various objects/classes that make up your application and specify the
relationship between them.
This month, we'll build a very basic version of the VerySimpleText application, based
on a tutorial presented by the NeXT folks at Apple's World-Wide Developer's
Conference. Don't be fooled, though: the pre-built objects that ship with OPENSTEP
will give this version of VerySimpleText some pretty powerful capabilities. In the
coming months, we'll continue to muck around with VerySimpleText, demonstrating
just how easy it is to work with the OPENSTEP objects.
The version of Project Builder and Interface Builder I've got installed on my system
(OPENSTEP 4.2) are a bit buggy. Nothing too awful -- mostly I find myself having to
repeat a command or mouse click as Interface Builder seems to swallow (or ignore)
the occasional event.
Though these bugs have been verified by some of the NeXT folks, I'm guessing that by
the time this issue of MacTech hits the streets, a new version of OPENSTEP will be
available and some of these bugs will no longer exist. Bottom line, if you are trying to
reproduce the steps in this column and things don't go exactly as planned, patience! Try
backing up and repeating the last step.
Oh yeah, thanks as usual to Michael Rutman for his excellent tech review...
Building the VerySimpleText Project
• Launch ProjectBuilder (either from the dock - it's the hammer icon - or
from myhost/NextDeveloper/Apps/ProjectBuilder.app).
• Select New from ProjectBuilder's Project menu.
• When the "New Project" panel appears (a panel is a dialog box), navigate
to the folder in which you want your project folder stored. ProjectBuilder
will build a new folder for you using the project name you specify in the next
step.
• Type VerySimpleText.01 in the Name field.
• Select Application from the Project Type popup menu.
Before you click the OK button, compare your panel to the one shown in Figure 1.
Figure 1. The New Project Panel used to create the VerySimpleText.01 project in
ProjectBuilder.
• Click the OK button.
ProjectBuilder will create a new folder named VerySimpleText.01 into which it will
place the files it needs for your new project. In ProjectBuilder, a new project window
will appear (see Figure 2). The project window lets you browse through all the files
used to build your project, including a special series of files, similar to resource
files, closer still to Constructor files, known as .nib files. The .nib files are used by
InterfaceBuilder to define your program's interface.
Figure 2. The project window created by ProjectBuilder.
Check out the project window shown in Figure 2. Notice that the interfaces section is
highlighted showing the list of .nib files in this project. In this case, we've got one .nib
file for NEXTSTEP, and another for Windows. Since I'm running the NEXTSTEP OS, I'll
work with the NEXTSTEP .nib file. If you are running NEXTSTEP on top of Windows,
you'll want the Windows .nib file. By the time this column hits the streets, you may
have a third alternative: a Rhapsody .nib file!
• Double-click the NEXTSTEP_VerySimpleText.01.nib file in the
ProjectBuilder browser, Interfaces section. This will launch
InterfaceBuilder.
Note that ProjectBuilder's main menu has the title PB and InterfaceBuilder's main
menu has the title IB. If you are confused as to which application you are in, just check
out the menu window.
InterfaceBuilder features a number of windows you'll get to know and love. The plain
window labeled "My Window" is your application's window (Figure 3). The inspector
window gives you info about and lets you modify the currently selected element. At the
moment, the inspector is a window inspector and lets you modify the application
window (Figure 4). The palette window lets you drag various interface elements into
place to become part of your application (Figure 5). Various palettes are available.
Your application comes with a main menu that you can modify as you like. The main
menu looks just like a regular menu (Figure 6), so you might be confused the first
time you look for it. By default, the menu's title is nextstep (assuming you are using
the NEXTSTEP .nib). Finally, InterfaceBuilder's main window (Figure 7) lets you
work with your projects object instances, classes, sounds, and images. This window is
more commonly known as the .nib window. You'll learn more about these windows as
we go.