background image
C H A P T E R 1 3
Drawing and Graphics
Using the Drawing Interface
13-21
You can also use
MakePict
:
myText := MakePict([{penpattern: 0, font: ...}, rect,
{font: ...}, txtshape], {font: ...});
You can set the font in locations with
MakePict
. In this case the font gets
"encapsulated" into the PICT.
If the
{penpattern}
frame was not present in the picture shape, any of the above
places should suffice to set the font.
PICT Swapping During Run-Time Operations
13
To set a default picture for a
clPictureView
, use NTK's picture slot editor to set
the
icon
slot of the
clPictureView
. You may select a PICT resource from any
resource file that has been added to your project. The picture will be converted on
the Macintosh from a type 1 or 2 PICT into a bitmap, and stored in your package at
compile time. To change this picture at run time, you need to keep a reference to
each alternate picture or bitmap. This is done using
DefConst
at compile time in
a text file as follows:
OpenResFile(HOME & "Photos Of Ralph.rsrc");
// Here we convert a PICT 1 or PICT 2 into a BitMap.
// This is what NTK's picture slot editor does.
DefConst('kPictureAsBitMap,
GetPictAsBits("Ralph", nil));
// Here the picture is assumed to be in PICT 1 format.
// If it is not, the picture will not draw and you may
// throw exceptions when attempting to draw the object.
DefConst('kPictureAsPict,
GetNamedResource("PICT", "Ralph", 'picture));
// Verify this is a Format 1 PICT object!
if ExtractWord('kPictureAsPict, 10) <> 0x1101 then
print("WARNING: Ralph is not a Format 1 PICT
resource!");
// This is one way to get the picture's bounds
// information. You can also extract it from the
// picture's own bounds rectangle at either compile time
// or run time, by using ExtractWord to construct each
// slot of a bounds frame.
DefConst('kPictureAsPictBounds,
PictBounds("Ralph", 0, 0));
CloseResFile();
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна