home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
linuxmafia.com 2016
/
linuxmafia.com.tar
/
linuxmafia.com
/
pub
/
linux
/
macos
/
ResEdit_2.1.3.sea.hqx
/
PExamples
/
Obj
/
Source
/
ICON.Pick.p
< prev
next >
Wrap
Text File
|
1994-07-15
|
5KB
|
167 lines
{
COPYRIGHT (C) 1984-1990 Apple Computer,Inc.
All rights reserved
}
UNIT IconPick;
{ Icon Resource Picker }
{ This is the Icon resource picker example.
The general scheme is that a List structure is created whose cells
contain the ID's of this resource type. A drawproc is installed in the List
record which is called to display the resource. }
INTERFACE
USES MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf,
ResEd;
TYPE
IconPickPtr = ^IconPickRec;
IconPickHandle = ^IconPickPtr;
IconPickRec = RECORD
father: ParentHandle;{ Back ptr to dad }
fName: STR255;
wind: WindowPtr; { Picker window }
rebuild: BOOLEAN;
spare: BOOLEAN;
windowType: PossibleWindowTypes;
theResType: ResType; { Type of the resource being picked or edited. }
theResFile: INTEGER; { The home resfile of the window. }
codeResID: INTEGER; { Resource ID of the RSSC resource containing the picker or editor. }
spare1: Handle; { Not used here}
rType: ResType; { Type for picker - could be different from theResType }
rSize: LONGINT; { Size of a null resource }
minWindowWidth: INTEGER; { Used when the window is grown. }
minWindowHeight:INTEGER;
instances: ListHandle; { List of instances }
nInsts: INTEGER; { Number of instances }
viewBy: ViewTypes; { Current view type }
showAttributes: BOOLEAN; { Show attrs in window? }
ldefType: ResType; { Which LDEF to use }
theViewMenu: MenuHandle; { The picker view menu }
viewMenuMask: LONGINT; { Which items are enabled? }
cellSize: Cell; { Cell size for special view. }
iconMenu: Menuhandle; { our menu }
END;
PROCEDURE EditBirth(thing: Handle; dad: ParentHandle);
PROCEDURE PickBirth(t: ResType; dad: ParentHandle);
PROCEDURE DoEvent(VAR evt: EventRecord; pick: IconPickHandle);
PROCEDURE DoInfoUpdate(oldID, newID: INTEGER; pick: PickHandle);
FUNCTION IsThisYours (thing: Handle; pick: PickHandle): BOOLEAN;
PROCEDURE DoMenu(menu, item: INTEGER; pick: IconPickHandle);
IMPLEMENTATION
CONST
iconMenuID = 10; { This just uses one of ResEdit's menus. }
listCellSizeH = $38;
listCellSizeV = $42;
{ Needs to be 2 wide so that I can always tell a 2d list from a normal text list. }
minIconsPerRow = 2;
ICONMinWindowWidth = (minIconsPerRow * listCellSizeH) + theScrollBar;
ICONMinWindowHeight = listCellSizeV;
{$R-}
PROCEDURE EditBirth(thing: Handle; dad: ParentHandle);
BEGIN
END;
{ *********************************************************************************** }
PROCEDURE PickBirth(t: ResType; dad: ParentHandle);
VAR
pick: IconPickHandle;
theIconMenu: Menuhandle; { our menu }
BEGIN
pick := IconPickHandle(NewHandle(SIZEOF(IconPickRec)));
WITH pick^^ DO
BEGIN
father := dad; { Back ptr to dad }
rType := t; { Resource type }
viewBy := viewBySpecial;
ldefType := t;
cellSize.h := listCellSizeH;
cellSize.v := listCellSizeV;
minWindowWidth := ICONMinWindowWidth;
minWindowHeight := ICONMinWindowHeight;
END;
IF NOT DoPickBirth(noColor, TRUE, graphical2DPicker, ResEdId, PickHandle(pick)) THEN
DisposHandle (Handle(pick))
ELSE
BEGIN { Setup the snd menu }
theIconMenu := GetMenu (iconMenuId);
DetachResource (Handle(theIconMenu)); { Get our own copy. }
pick^^.iconMenu := theIconMenu;
END;
END;
{ *********************************************************************************** }
{ Everything is taken care of for us by PickEvent.}
PROCEDURE DoEvent(VAR evt: EventRecord; pick: IconPickHandle);
BEGIN
PickEvent(evt, PickHandle(pick));
IF evt.what = activateEvt THEN
BEGIN
IF ODD(evt.modifiers) THEN
InsertMenu(pick^^.iconMenu, 0)
ELSE
DeleteMenu(iconMenuId);
DrawMBarLater (FALSE);
END;
END;
{ *********************************************************************************** }
{ Everything is taken care of for us by PickInfoUp }
PROCEDURE DoInfoUpdate(oldID, newID: INTEGER; pick: PickHandle);
BEGIN
PickInfoUp(oldID, newID, pick);
END;
{ *********************************************************************************** }
FUNCTION IsThisYours (thing: Handle; pick: PickHandle): BOOLEAN;
BEGIN
IsThisYours := FALSE;
END;
{ *********************************************************************************** }
PROCEDURE DoMenu(menu, item: INTEGER; pick: IconPickHandle);
BEGIN
IF menu = iconMenuId THEN
BEGIN
{ Do something with the menu}
END
ELSE
BEGIN
IF (menu = fileMenu) & (item = closeItem) THEN
BEGIN
DeleteMenu(iconMenuId);
DrawMBarLater (FALSE);
DisposHandle (Handle(pick^^.iconMenu));
END;
PickMenu(menu, item, PickHandle(pick));
END;
END;
END.