home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-07-10 | 1.8 KB | 74 lines | [TEXT/MPS ] |
- {
- COPYRIGHT (C) 1984-1990 Apple Computer,Inc.
- All rights reserved
- }
- UNIT IconLDEF;
-
- INTERFACE
-
- Uses MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf,
- ResEd;
-
- PROCEDURE DrawCell( Message: INTEGER; lSelect: BOOLEAN; lRect: Rect; lCell: Point;
- lDataOffset, lDataLen: INTEGER; lh: ListHandle );
-
- IMPLEMENTATION
-
- PROCEDURE DrawIcon (lRect: Rect; theIcon: Handle);
-
- CONST IconSize = 128;
-
- BEGIN
- IF (SizeResource(theIcon) >= IconSize) THEN
- PlotIcon(lRect, theIcon);
- END;
-
- { This is the custom drawProc for the list (which contains the resource ID's). It
- simply draws the icon in the given rect and frames a selection rect around it if
- told to.
- NOTE: This is used by both ICON and ICN# pickers. }
- PROCEDURE DrawCell(Message: INTEGER; lSelect: BOOLEAN; lRect: Rect; lCell: Point;
- lDataOffset, lDataLen: INTEGER; lh: ListHandle);
-
- VAR
- theIcon: Handle;
- id: INTEGER;
- wasLoaded: BOOLEAN;
-
- { This routine simply looks up in the list at the given cell, extracts the ID and
- gets the resource called for. Returns NIL if not found. Note, this assumes
- the resfile is set up correctly }
- FUNCTION IconFetch(lCell: point; lHandle: ListHandle): Handle ;
-
- VAR
- len: INTEGER;
- err: OsErr;
- tempH:Handle;
-
- BEGIN
- IconFetch := NIL;
- len:=2;
- LGetCell(@id, len, lCell, lHandle); { Get the ID from the list. }
- IF len > 0 THEN
- BEGIN { Load the resource since we want to draw it. }
- tempH := REGet1ResourceSpecial(PickHandle(lHandle^^.refCon)^^.theResFile, PickHandle(lHandle^^.refCon)^^.rType, id, wasLoaded, err);
- IconFetch := tempH;
- END;
- END;
-
- BEGIN { DrawCell }
- CASE message OF
- lDrawMsg, lHiliteMsg:
- BEGIN
- theIcon := IconFetch(lCell, lh);
-
- DrawLDEF (message, lSelect, lRect, theIcon, id, '', 32, 32, @DrawIcon, lh);
-
- IF (theIcon <> NIL) & (NOT wasLoaded) THEN
- HPurge(theIcon);
- END;
- END;
- END;
-
- END.
-