Applet
Toolkit 3.0.3
UserLand Software, Inc.
©
copyright 1992-94, UserLand Software, Inc.
UserLand
Software is the developer of the UserLand Frontier scripting system. The
company is located at 555 Bryant #237, Palo Alto, CA 94301. 415-326-7791,
415-326-7793 (fax). UserLand, Frontier, Frontier Runtime and Frontier Extras
are trademarks of UserLand Software, Inc. Other product names may be trademarks
or registered trademarks of their owners.
Email:
userland.dts@applelink.apple.com. If youÕre an AppleLink user, check out the
UserLand Discussion Board under the Third Parties icon. CompuServe users enter
GO USERLAND at any ! prompt. The UserLand Forum is in the Computing Support
section on CompuServe. On America On-Line, enter the keyword USERLAND.
Comments,
questions and suggestions are welcome!
Background
The
Applet Toolkit makes it simple to build new double-clickable Macintosh
applications that have strong support for Apple Events and menu sharing.
If
youÕre developing a new application specifically to be integrated with other
software, the Applet Toolkit is a perfect choice.
UserLandÕs
DocServer application is implemented using the Applet Toolkit, as are all new
applications and utilities in development at UserLand.
Two
sample applications are provided. Minimal Applet is a simple multi-window text
editor, BarChart is a color charting program.
Sample Apps
BarChart
The best way to learn about the Applet Toolkit is to
examine an application that's built on it. BarChart is the simplest applet.
Open the BarChart.¹ project file and open barchart.c.
Look at it's main () routine.
You'll see that it starts by clearing the app record
and then setting a few fields:
clearbytes
(&app, longsizeof (app)); /*init all fields to 0*/
app.creator
= 'BARC';
app.filetype
= 'CHRT';
app.usecolor
= true;
app.resizeable
= true;
This tells the Applet Toolkit to save newly created
files with 'BARC' as their creator id, and to set the file type to 'CHRT'.
Because BarChart sets the usecolor field to true, when new windows are created
they will be color windows. Finally it says that BarChart's windows can be
resized.
There are many other fields that BarChart could have
set to allow for scroll bars, a tool palette, or a status area in each window
that's created. See the definition of tyappletrecord in applet.h for complete
information.
Then BarChart establishes a set of callback routines
that are activated when certain events operations need to be performed. For
example, when a window needs updating, bcupdate is called.
Finally it calls runapplet, which processes events
and calls barchart.c callback routines when necessary.
Minimal Applet
Despite its name, this program is a much more
complete user of the Applet Toolkit than BarChart.
It supports horizontal and vertical scrolling,
processes keystrokes and mouse events, and has real support for the clipboard.
Applet Toolkit 3.0.3 -- 7/27/94 dmb
Universal
Headers, PowerPC compatibility
The Applet Toolkit can now be built using AppleÕs
Universal Headers under Symantec C/C++ 7.0 or Metrowerks C/C++ 1.0 68K or PPC.
Native or Òfat binaryÓ applications can be generated in the Code Warrior
environment. Also, modern, ANSI-conformant function prototypes are used
thoughout the code, so strict error checking can be enforced for Applet Toolkit
projects.
Applet Toolkit 3.0b10 -- 11/4/93 DW
Lots of changes
in the Applet Toolkit
Two new pieces of software in development at UserLand
have forced the Applet Toolkit to become much more mature and complete, and
more debugged. The changes in the Applet Toolkit arenÕt documented in this
release. The Applet Toolkit is still very much a work in progress.
Following are notes taken while converting BarChart
and MinApp to work with the new toolkit. Hopefully they will highlight any
changes you need to make to convert your projects to the new version of the
Applet Toolkit.
We also havenÕt tried too hard to hide where weÕre
going. YouÕll see comments in the following section that talk about features
that are not supported by this version of the toolkit, but will be supported in
future versions.
Most notable is the next step in the evolution
of ÒsharingÓ protocols. Eventually
we will transition to a more powerful API called ÒUI Sharing,Ó which supports
menu sharing, and window sharing. If
youÕre interested, you can browse the Applet Toolkit to see how it will build
on this new capability. Coming soon, we hope!
Swap out UI
Sharing calls, replace with menu sharing
UI sharing support is compiled only if ÒuiSharingÓ is
defined, otherwise we use the Menu Sharing Toolkit.
Replace
appletcard.c with appletdialogs.c
Add appletabout.c.
Turn on the
Window menu
In barchart.c, sett app.haswindowmenu to true. Add a
MENU 136 resource to barchart.¹.rsrc.
Use temporary
memory
In barchart.c, set app.usetempmemory to true.
Smarter about
overwriting grow box
BarChart is a wierd applet -- it has growable
windows, but no scroll bars.
In barchart.c, bcupdate routine, we avoid erasing the
windowÕs grow box.
Build MinApp
Worked fine, the first time through.
Turned on temp memory and the Window menu, as with
BarChart.
Tweak up shared
scripts
Took out msg call in 50 Upper/Lowers (want to see how
fast it can be).
Insert 50 States inserts 50 strings instead of
building up one string and inserting it.
Added ÒSystem Folder ListingÓ script. Nice!
BarChart window
updating
When you switch BarChart into the background itÕs
supposed to redraw its highlighted window with a white background and fill the
bars with a gray pattern. This isnÕt happening. Why?
There was a change in the Applet Toolkit (obviously!)
-- instead of calling the activate callback when the applet is switched out, it
calls a new callback routine, app.switchcallback. Fixed the problem by adding
the following:
app.switchcallback
= (tyappbooleancallback) &bcactivate;
to main
() in barchart.c. The active window in BarChart now updates correctly.
Disproportionate
bars in BarChart
Peter Dako reports that when two bars in the same
chart have wildly different values, like 18944 and 8580962, thereÕs some kind
of problem displaying the chart. LetÕs see...
Found the problem, but didnÕt fix it. BarChart
computes the height of the bars using integer arithmetic, and when you resize
the window, the arithmetic can overflow, yielding negative numbers that should
be positive. BarChart is a demo program.
I hear that DeltaGraph is scriptable!