background image
C H A P T E R 1 3
Drawing and Graphics
13-20
Using the Drawing Interface
Importing Macintosh PICT Resources
13
The following information applies to the Mac OS version of NTK; the Windows
version differs. See the Newton Toolkit User's Guide for details.
A Macintosh PICT resource can be imported into the Newton in two ways: as a
bitmap or as a picture object. A Macintosh PICT resource is stored much more
compactly on the Newton as a picture object; however, it may be slower to draw
than a bitmap. The same Macintosh PICT resource may occupy much more space
when imported as a bitmap, but may draw significantly faster. The method you
should use depends on whether you want to optimize for space or speed.
A Macintosh PICT resource is imported as a bitmap by using the slot editor for the
icon
slot (an editor of the picture type). Alternatively, the resource can be
imported as a picture object by using the
GetResource
or
GetNamedResource
compile-time functions available in NTK. In this case, you must use an
AfterScript
slot to set the value of the
icon
slot to the picture object obtained
by one of these resource functions.
Note
The constant
clIconView
can also be used to indicate a
view of the
clPictureView
class. These two constants
have identical values.
Here is an example of a template defining a view of the
clPictureView
class:
aPicture := {...
viewClass: clPictureView,
viewBounds: {left:0, top:75, right:150, bottom:175},
viewFlags: vVisible+vClickable,
icon: myPicture,
...}
Drawing Non-Default Fonts
13
You can draw a font other than the default font by putting the font specifier style
frame close to the text shape so that another style frame won't override it. Use
either
DrawShape
or
MakePict
.
There are several places where it might seem reasonable to put the style frame with
the font specifier.
DrawShape
takes a style argument, so you could place it there:
:DrawShape(myText, {font: '{family: someFont,
face: 0, size: 9 }});
You can embed a style frame in an array of shapes:
:DrawShape ([{font: ...}, myText, shape ], nil);
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна