AppSketcher: Classes and the Class Viewer
To add objects to your interface module, you drag and drop "class"
items into the
Instance Viewer or Module Window of your AppSketcher
module.
AppSketcher's Class Viewer window
displays the class items that
you can click on and drag. But that's not the only place to find
a class: Each class item is equivalently represented in a number
of ways, and each of these equivalent class "containers" can be used
as the source of a drag. To be explicit, a class item
can be dragged out of any of the following:
Which container you use is a matter of personal taste and
convenience--these are simply different ways of
looking at the same thing.
The following sections examine each of these containers,
with a particularly
long look at the Class Viewer window.
AppSketcher's Class Viewer window displays the classes that
AppSketcher knows about. By dragging an
item out of the Class Viewer and dropping it into your
AppSketcher module, you cause an instance of that
class to be added to your module.
By default, the Class Viewer lists all the
classes that are defined by the Be software kits. You can
add your own classes
simply by dropping their definitions (".h" header files) into the
Viewer. You
can also remove unwanted classes, and reload classes that have
changed through the commands in the
Class
and
Edit menus.
The Class Viewer window is automatically shown when you
launch AppSketcher.
If you've dismissed your Class Viewer window,
or if it's gotten
buried, you can use the
Class Viewer command (alt-y) in AppSketcher's
main menu
to bring it back to the front.
The graphical attributes and behaviours of the Class Viewer are these:
-
The Class Viewer expresses the C++ class hierarchy of its contents,
reading across
its columns from left to right.
By selecting a class in a column,
you are shown the direct descendants of that class in the
next column to the right. For example, in the Class Viewer
shown here, the left-most column shows the "base" classes, the next
column lists the direct descendants of BObject, and the right column
shows the direct descendants of BHandler.
-
The Class Viewer
maintains and displays a current selection upon which the
menu commands operate.
The current selection is drawn in dark gray; the hierarchical path
that leads to the selection is shown in light gray.
To set the current selection, you click on the desired class
in the Class Viewer.
-
Double-click to view a header file.
When you double-click on a class in the Class Viewer,
the header file for
the class is opened (and displayed) by the Edit application.
-
You never need to save a Class Viewer.
Nor can you save it--there's no facility for doing so.
Any modifications
that you make to the Viewer's contents are effective immediately and
persistently.
-
The Class Viewer is global and singular.
The Class Viewer lists all the classes that are available
to all AppSketcher modules. You can't, for example, create
a "custom" Class Viewer for a particular module: All the modules
that you have open will draw their class items from the same
Class Viewer window. AppSketcher can only display one Class Viewer
window.
-
To display a particular class, all its ancestors must be defined.
Although
the Class Viewer might know about an "orphan" class, it won't be able
to present the class until all the ancestors of that class have been imported.
For details on exactly what the Class Viewer is showing you, and where
it gets its list of classes, see the
Class table description.
There are two menus in the Class Viewer's menu bar:
Class and Edit. Through the commands in these
menus, you can add and remove classes from the Viewer, and
find classes in the Viewer's hierarchical display.
If you're adding your own
classes, you should also see
"Add your own Classes"
for distilled instructions and caveats.
The Class menu commands let you load (or import)
and reload class definition files.
-
In all cases, the classes must be defined in header files
that have a ".h" extension.
A single header file can contain any number of class
definitions; when you import a file, all the classes that are
found in the file are read and imported.
The Class menu commands are these:
-
The Import... commands present File Open Panels
that you can navigate to find the file or folder that you want.
When you import a folder, all the .h files within the folder
and all its subfolders are
imported. In both cases (importing a single file and importing
a folder), a status bar shows you the importer's progress.
-
The Reload class command re-imports the definition
of the currently selected item in the Class Viewer. Typically, you
use this command as you refine the definition of one of your own classes.
When
you make a change to a class definition, you must reload the
class, or the AppSketcher won't see the changes.
- The Reload all classes command re-imports all the classes
that are currently in the Class Viewer (even those that aren't currently
visible). You should rarely need to use this command.
-
While AppSketcher is loading a class, DON'T touch the
AppSketcher icon that's displayed by the Browser (in the upper
right corner of the dock). If you do, the Browser will be frozen
until you kill AppSketcher.
- Hide Class Viewer closes the Class Viewer window. If this
is the only window that AppSketcher has open, you'll be asked if you
want to quit the application. To bring a "hidden" Class Viewer
window back to the front, use the
Class Viewer command (alt-y) in AppSketcher's
main menu.
-
You can import or reload classes by dragging and
dropping individual files
or entire folders onto the Class Viewer window.
It doesn't matter where you drop the file/folder icon;
the classes will be read and added to the
appropriate branches of the class hierarchy.
-
When importing a class, note that only the definition (header file)
is important.
The class needn't be compiled nor even implemented.
Of course, you'll need the implementation when you
compile your application, but to construct the interface all you need
is the header file.
-
Classes don't have to be added in hierarchical order.
If you import an "orphan" class--a class that inherits from a
class that hasn't been imported
yet--the loader will import your orphan, but the
Class Viewer won't display it. After all the ancestors have been
imported, the original class will show up in the Viewer.
The ancestor classes are not automatically found and loaded.
-
Importing an existing class is the same as reloading the class.
For example, if you want to reload a folder's worth of files, you can
use Import classes from folder....
This, obviously, is easier than calling Reload class on each
class.
-
When you reload a particular class, all other classes that are
defined in its header file are also reloaded.
-
Reloading a class that you're editing works best
if you use the BeIDE editor (as opposed to Be's
Edit application).
AppSketcher remembers header files by their record_refs.
Edit, however, changes the ref every time you save the file; because
of this, the Reload class command doesn't work if you're
making changes with Edit.
The Edit menu commands let you find
and remove individual classes.
-
The Remove command removes the currently selected
class and all its descendants from the Class Viewer.
This doesn't destroy
the header files from whence the class(es) sprang, it simply removes
the class item(s) from the Class Viewer.
More accurately, the
Remove command
deletes the Class record that corresponds to the
selected item; the descendant records, however,
are not deleted. The fact that the descendants
disappear from the Class Viewer is an artifact of the
Viewer's hierarchical display. See the
Class table
description for more on Class records.
-
Removing a class can take a few seconds.
Currently, AppSketcher doesn't give you any indication that it actually
heard your request and is busy removing the unwanted class. Eventually,
however, it will remove the selected item from the Class Viewer.
-
Keep in mind that your Class Viewer actions are global.
If you remove a class that's needed by an existing module, and then
you try to open that module, the open will be denied.
-
The Find command brings up a Find Panel into which you can
enter the name of the class that you want to find. If the class is
found, the Class Viewer selects it and scrolls to bring it into view.
The string comparison is case-sensitive and can contain "*" as
a wildcard, as shown below.
- The Next command re-performs the previous Find. If
you used a wildcard that hit more than one class, Next will
find the next hit. In the panel shown here, the first Find
will lead to the Game Kit's BWindowScreen; a subsequent Next
will find BWindow. (Class names are found in a consistent but
curious order.)
A palette is a convenient non-hierarchical list of often-used classes.
You ask for a
new, empty palette through the New Palette command
in AppSketcher's
main menu.
(The command doesn't have a keyboard shortcut.)
When you create a new palette, AppSketcher first asks you to
save it, and then displays an empty palette window. You can
then drag your favorite classes out of the
Class Viewer and drop them into the palette.
-
To save a palette once you've loaded it with classes:
Bring its window to the front and type alt-s.
-
To open an existing palette: You can double-click its file icon (shown here),
or drop the icon onto the AppSketcher
application icon, or into the Class Viewer window.
The purpose of a palette is
to provide a convenient way to get to common classes.
By creating a palette of (for example) all the menu classes (as shown
here) you can avoid having to hunt all over the Class Viewer
everytime you want to create a menu--instead, you simply
drag the menu classes from the palette and drop them into your
module.
Some more palette facts:
-
Dragging a class into a palette doesn't remove the class from
the Class Viewer.
The two images of the class (the one in the
Class Viewer and the one in the palette) refer to the same
underlying Class record.
-
Palettes don't "belong" to particular modules.
Any palette can be used
with any module.
-
You can display
a class' header file by double-clicking the class in the palette.
This works exactly as it does in the Class Viewer.
-
You can't remove a class from a palette directly.
However, when you
remove a class from the Class Viewer, the class is also removed from
all open palettes that it's a part of.
Each class that's listed in the Class Viewer represents a
record that conforms to the Class table. This table is automatically
created when you launch AppSketcher for the first time. The fields of the
Class table supplies some useful information about the
AppSketcher classes; you can get to the table and list the field values
by forming a Browser query (through the Browser's Find command). The
result of such as query, with the fields popped up, is shown here.
-
You can drag class records out of a Browser Query window and drop them into
your AppSketcher module.
Dragging and dropping a Class record performs exactly the same
function as dragging a class item from the Class Viewer.
-
Double-clicking a Class record finds the class in the
Class Viewer.
If AppSketcher isn't currently running, double-clicking a Class
record will launch the app.
-
Don't manipulate Class records directly.
It's possible to delete Class records, rename them, move them,
and so on, by editing the fields in a Query window,
but AppSketcher won't know about the changes until you re-launch
the app.
When AppSketcher first creates the Class table, it
adds the table to the database
of the volume in which the AppSketcher
executable resides. For example, if you load AppSketcher onto the
boot volume (a reasonable location), then the Class table
will be created in the database for the boot volume. This could
cause some confusion if you have more than one hard disk with a copy of
AppSketcher on each one.
To fill the table with its initial records,
AppSketcher reads the header files
that it finds
in the current volume's develop/be/headers directory. If
the directory isn't found (because you've moved it, presumably),
AppSketcher will try to find it. If it can't find the directory, you're
prompted for
its location.
-
Be assured that the Class table isn't referred to when you
launch an application that was born in AppSketcher.
The Class table is only needed while you're working with AppSketcher.
If you change the table, you won't break existing applications (although
you may break their AppSketcher modules--see the warning in the
Edit menu description). Similarly, you can
run an AppSketcher-designed application on a computer that, for example,
doesn't even have a Class table. It will still work.
For each Class record, there is a corresponding Class file.
A Class file contains information that
completes the Class record--but more than that,
by poviding a file interface to the
Class records, AppSketcher gives you yet another way to
organize the classes
that you drag and drop
into your module.
The collection of Class files is contained in the Classes subdirectory of the
AppSketcher package. When you browse Classes, you'll see two
subdirectories, lorienne and be. The former contains
classes that AppSketcher needs; the latter contains the Class files for
the Be kit classes.
By default, the Be classes are distributed into subdirectories that
correspond to the Be kits, as shown to the left.
The Class files for the classes that you add to AppSketcher (through
Class menu commands) are added directly
to the Classes directory--they aren't stuffed into
subdirectories.
There are three aspects to the Class files that you should
be aware of:
-
Class files aren't header files.
The files are part of the Class records that AppSketcher
uses. You shouldn't modify the Class files, nor should
you try to add a new class to AppSketcher by copying
(and changing the name of)
an existing Class file.
-
The existence of a Class file doesn't mean the class has been imported.
In fact, when you first unpack AppSketcher, you'll find that the Classes
directory is already filled with Class files.
Nonetheless, the Be headers files still must be read.
-
The organization of files and subdirectories within the Classes
directory
isn't sacred.
You can redistribute the files or even move them out of the Classes
folder if you want (but do keep them on
their original volume),
-
You can drag and drop Class files into your interface just as
you would class entries in the Class Viewer.
Taken together, these last two points
mean that you can create a specialized directory to hold certain Class
files, open the directory as a Browser Folder, and then drag
the files out of the folder and into AppSketcher. In other words,
your folder can act as a sort of Palette.
For example,
the folder shown to the right gives a list view of the
menu classes moved into their own MenuClasses directory. You could
drag and drop the file icons into your AppSketcher module and so
add instances of these classes to your module.
|
Copyright ©1997 BeatWare Incorporated. All rights reserved. Reproduction in
whole or in part in any form or medium without express written permission of BeatWare, Inc. is
prohibited.
Be is a registered trademark, and BeOS, BeBox, BeWare, GeekPort, the Be logo and the BeOS logo
are trademarks of Be, Inc. All other trademarks mentioned are the property of their respective owners.
Comments about this page? Please write us at webmaster@beatware.com.
All rights reserved.
|
|