3 Sample WASTE Object Handlers
5 Copyright © 1993-1998 Marco Piovanelli
9 #include "WEObjectHandlers.h"
21 pascal OSErr
HandleNewPicture(Point
*defaultObjectSize
, WEObjectReference objectRef
)
26 /* get handle to object data (in this case, a picture handle) */
27 thePicture
= (PicHandle
) WEGetObjectDataHandle(objectRef
);
29 /* figure out the default object size by looking at the picFrame record */
30 frame
= (*thePicture
)->picFrame
;
31 OffsetRect(&frame
, -frame
.left
, -frame
.top
);
32 defaultObjectSize
->v
= frame
.bottom
;
33 defaultObjectSize
->h
= frame
.right
;
38 pascal OSErr
HandleDisposePicture(WEObjectReference objectRef
)
42 /* get handle to object data (in this case, a picture handle) */
43 thePicture
= (PicHandle
) WEGetObjectDataHandle(objectRef
);
45 /* kill the picture */
46 KillPicture(thePicture
);
51 pascal OSErr
HandleDrawPicture(const Rect
*destRect
, WEObjectReference objectRef
)
55 /* get handle to object data (in this case, a picture handle) */
56 thePicture
= (PicHandle
) WEGetObjectDataHandle(objectRef
);
58 /* draw the picture */
59 DrawPicture(thePicture
, destRect
);
67 pascal OSErr
HandleNewSound(Point
*defaultObjectSize
, WEObjectReference objectRef
)
69 #pragma unused(objectRef)
71 /* sounds are drawn as standard 32x32 icons */
72 defaultObjectSize
->v
= 32;
73 defaultObjectSize
->h
= 32;
78 pascal OSErr
HandleDrawSound(const Rect
*destRect
, WEObjectReference objectRef
)
80 #pragma unused(objectRef)
82 /* draw the sound icon */
83 return PlotIconID(destRect
, kAlignNone
, kTransformNone
, kSoundIconID
);
86 pascal Boolean
HandleClickSound(Point hitPt
, EventModifiers modifiers
,
87 UInt32 clickTime
, WEObjectReference objectRef
)
89 #pragma unused(hitPt, clickTime)
91 SndListHandle theSound
;
93 /* WASTE sets the low bit of modifiers on double (multiple) clicks */
94 if (modifiers
& 0x0001)
97 /* get a handle to the object data (in this case, a sound handle) */
98 theSound
= (SndListHandle
) WEGetObjectDataHandle(objectRef
);
101 SndPlay(nil
, theSound
, false);
103 /* return TRUE so WASTE knows we handled the click */
108 /* not a double click: let WASTE handle the mouse-down */