Title Banner

Previous Book Contents Book Index Next

Newton Developer Technical Information: Newton Programmer's Guide: 2.1 OS Addendum /
Chapter 2 - Newton Works Draw Application / Using the Drawing Application Interface


Adding Stamps to the Stamp Tool

To add stamps to the stamp palette, use the *RegStamps method of the Draw application's viewDef. This method takes two arguments, a uniquely identifying symbol and an array of stamps. The stamp array should contain no more than 24 stamps, since the stamp palette only displays 24 stamps at a time. If you wish to add more than 24 stamps, make more than one array, and call *RegStamps separately for each array.

The stamps can be pix families or picture objects, and should be less than 1 KB. For information on pix families and picture objects, see Chapter 6, "Drawing and Graphics 2.1." There is no limit on the size of the image, but you must be aware of the memory consumption.

Note
The image is stored in a soup, so you are ultimately limited by the maximum size of a soup entry (currently 64 KB). Soups are described in Chapter 11, "Data Storage and Retrieval,"in Newton ProgrammerŐs Guide.
The Draw application's viewDef contains an *UnRegStamps method to remove stamps added with *RegStamps.

Stamps are usually added in an auto part package. The sample code below shows the full content of a text file that creates such an auto part.

Listing 2-3 Adding stamps to the Draw application

OpenResFile( Home & "myResourceFile" );

//Note that only stamp6 really needs 16 grays, and some stamps are OK //using only 4 grays. This saves a lot of space over importing all the //stamps at a bit depth of 4. DefineGlobalConstant('kStampArray , [ MakePixFamily (nil,nil,{rsrcSpec :"stamp1", bitdepth : 1} ), MakePixFamily (nil,nil,{rsrcSpec :"stamp2", bitdepth : 1} ), MakePixFamily (nil,nil,{rsrcSpec :"stamp3", bitdepth : 1} ), MakePixFamily (nil,nil,{rsrcSpec :"stamp4", bitdepth : 2} ), MakePixFamily (nil,nil,{rsrcSpec :"stamp5", bitdepth : 2} ), MakePixFamily (nil,nil,{rsrcSpec :"stamp6", bitdepth : 4} ), ] ); CloseResFile();

InstallScript := func(partFrame, removeFrame)

begin local viewDef := GetViewDefs('drawPaper).default; local sym := EnsureInternal(kAppSymbol); if viewDef then viewDef:RegStamps(sym, kStampArray); end; RemoveScript := func(removeFrame) begin local sym := EnsureInternal(kAppSymbol); local viewDef := GetViewDefs('drawPaper).default; if viewDef then viewDef:UnRegStamps(sym); end;


Previous Book Contents Book Index Next

© Apple Computer, Inc.
26 APR 1997



Navigation graphic, see text links

Main | Top of Section | What's New | Apple Computer, Inc. | Find It | Feedback | Help