steele@cs.unc.edu (Oliver Steele) (05/20/88)
[ShowPict.c]
---
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# ShowPict.c
# This archive created: Thu May 19 07:49:57 1988
# By: Roger L. Long (bytebug@dhw68k.cts.com)
export PATH; PATH=/bin:$PATH
echo shar: extracting "'ShowPict.c'" '(2664 characters)'
if test -f 'ShowPict.c'
then
echo shar: will not over-write existing file "'ShowPict.c'"
else
sed 's/^X//' << \SHAR_EOF > 'ShowPict.c'
X/* File: ShowPict.c
X * Author: Oliver Steele
X * USENET: steele@cs.unc.edu
X * USNAIL: 1209 Mason Farm Rd. 27514
X * Purpose: display a PICT file
X * Date: 13 May 1985
X * Comments:
X * I release this code into the public domain.
X * This code was written quickly and dirtily.
X * I make no guarantees about it.
X */
X
X#include <MacTypes.h>
X#include <QuickDraw.h>
X#include <WindowMgr.h>
X#include <Color.h>
X#include <ColorToolbox.h>
X#include <EventMgr.h>
X#include <SegmentLdr.h>
X#include <FileMgr.h>
X#include <StdFilePkg.h>
X
Xextern int MBarHeight: 0xbaa;
X/*#define HasCQD() (!(ROM85&0x4000))
X#define mbHeight ((ROM85<0)?20:MBarHeight)
X*/
Xstatic int PICTRefNum;
X
Xpascal void GetPICTData(dp, n)
XPtr dp;
Xint n;
X{
X long count;
X
X count = n;
X FSRead(PICTRefNum,&count,dp);
X}
X
Xvoid DrawPICTFile(name,refnum)
XStringPtr name;
Xint refnum;
X{
X CQDProcs qdp;
X PicHandle ph;
X long count;
X Rect bounds;
X WindowRecord window;
X
X PICTRefNum = refnum;
X ph = (PicHandle) NewHandle(sizeof(Picture));
X
X SetFPos(PICTRefNum,fsFromStart,512);
X count = sizeof(Picture);
X FSRead(PICTRefNum,&count,*ph);
X
X bounds = (**ph).picFrame;
X OffsetRect(&bounds,-bounds.left,-bounds.top);
X OffsetRect(&bounds,
X (screenBits.bounds.right-bounds.right)/2,
X (screenBits.bounds.bottom-mbHeight-bounds.bottom)/2);
X if (bounds.left<0)
X InsetRect(&bounds,-bounds.left,0);
X if (bounds.top<0)
X InsetRect(&bounds,0,-bounds.top);
X OffsetRect(&bounds,0,mbHeight);
X
X if (HasCQD())
X NewCWindow(&window,&bounds,name,true,plainDBox,-1,false,0);
X else
X NewWindow (&window,&bounds,name,true,plainDBox,-1,false,0);
X
X SetPort(&window.port);
X SetStdCProcs(&qdp);
X qdp.getPicProc = (Ptr) GetPICTData;
X window.port.grafProcs = (QDProcsPtr) &qdp;
X
X OffsetRect(&bounds,-bounds.left,-bounds.top);
X DrawPicture(ph,&bounds);
X FSClose(refnum);
X while (!Button())
X ;
X CloseWindow(&window);
X}
X
Xvoid OpenAndDraw(name,vol)
XStringPtr name;
Xint vol;
X{
X int refnum;
X
X if (FSOpen(name,vol,&refnum)) {
X SysBeep(2);
X return;
X }
X DrawPICTFile(name,refnum);
X FSClose(refnum);
X}
X
Xmain()
X{
X int message, count;
X
X MaxApplZone();
X MoreMasters();
X
X InitGraf(&thePort);
X InitFonts();
X InitWindows();
X InitMenus();
X TEInit();
X InitDialogs(0);
X
X InitCursor();
X FlushEvents(everyEvent-diskMask,0);
X
X CountAppFiles(&message, &count);
X if (count) {
X int i;
X AppFile app;
X
X for (i = 0; i++<count; ) {
X GetAppFiles(i, &app);
X if (app.fType == 'PICT')
X OpenAndDraw(app.fName, app.vRefNum);
X }
X } else for (;;) {
X SFReply sf;
X int refnum;
X static Point where = {100,100};
X
X FlushEvents(everyEvent-diskMask,0);
X SFGetFile(where, 0, 0, 1, "PICT", 0, &sf);
X if (!sf.good)
X break;
X OpenAndDraw(sf.fName, sf.vRefNum);
X }
X}
SHAR_EOF
if test 2664 -ne "`wc -c < 'ShowPict.c'`"
then
echo shar: error transmitting "'ShowPict.c'" '(should have been 2664 characters)'
fi
fi # end of overwriting check
# End of shell archive
exit 0
---