home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
historic
/
v92.tgz
/
v92.tar
/
v92
/
src
/
runtime
/
rmacrsc.ri
< prev
next >
Wrap
Text File
|
1996-03-22
|
25KB
|
972 lines
/*
* File: rmacrsc.ri - Mac specific resource
*/
novalue MacMain Params((int argc, char *argv[]));
extern MouseInfoType gMouseInfo;
extern char *cmlArgs;
extern StringHandle textHandle;
/*
* allocate a context. Can't be called until w has a display and window.
*/
wcp alc_context(wbp w)
{
int i;
wcp wc;
GRFX_ALLOC(wc, _wcontext);
GRFX_LINK(wc, wcntxts);
/* set default values */
wc->contextPtr = malloc(sizeof ContextType);
SETCONTEXTDEFAULT(wc->contextPtr);
return wc;
}
/*
* allocate a window state structure
*/
wsp alc_winstate()
{
int i;
wsp ws;
GRFX_ALLOC(ws, _wstate);
ws->bits = 1024; /* echo ON; others OFF */
ws->filep = nulldesc;
ws->listp = nulldesc;
GRFX_LINK(ws, wstates);
return ws;
}
/*
* free a window state
*/
int free_window(wsp ws)
{
ws->refcount--;
if(ws->refcount == 0)
{
if (ws->theWindow != nil)
{
CloseWindow (ws->theWindow);
DisposeWindow (ws->theWindow);
}
GRFX_UNLINK(ws, wstates);
}
return 0;
}
/*
* free a window context
*/
novalue free_context(wcp wc)
{
wc->refcount--;
if(wc->refcount == 0)
{
GRFX_UNLINK(wc, wcntxts);
}
}
/*
* drawstrng
*/
void drawstrng(wbp wb, int x, int y, char *str, int slen)
{
STDLOCALS (wb);
SetPort (ws->theWindow);
COPYCONTEXT (wc->contextPtr);
MoveTo (x, y);
DrawText (str, 0, slen);
/*begin quote*/
PREPAREGWORLD (ws);
COPYCONTEXT (wc->contextPtr);
MoveTo (x, y);
DrawText (str, 0, slen);
UnlockPixels (ws->offScreenPMHandle);
SetGWorld (ws->origPort, ws->origDev);
/*end quote*/
}
void hidecrsr (wsp ws)
{
}
void showcrsr (wsp ws)
{
}
void getfntnam (wbp wb, char *answer)
{
Str255 fName;
STDLOCALS(wb);
GetFontName (wc->contextPtr->txFont, fName);
answer = PtoCstr (fName);
}
/*
* allocate a context, cloning attributes from an existing context
*/
wcp clone_context(wb)
wbp wb;
{
wcp wc, wc2 = wb->context;
wsp ws = wb->window;
Protect(wc = alc_context(wb), return NULL);
/*
* copy over some stuff
*/
memcpy (&(wc->contextPtr->bkPat), &(wc2->contextPtr->bkPat), sizeof Pattern);
memcpy (&(wc->contextPtr->fillPat), &(wc2->contextPtr->fillPat), sizeof Pattern);
wc->contextPtr->pnLoc = wc2->contextPtr->pnLoc;
wc->contextPtr->pnSize = wc2->contextPtr->pnSize;
wc->contextPtr->pnMode = wc2->contextPtr->pnMode;
memcpy (&(wc->contextPtr->pnPat), &(wc2->contextPtr->pnPat), sizeof Pattern);
wc->contextPtr->txFont = wc2->contextPtr->txFont;
wc->contextPtr->txFace = wc2->contextPtr->txFace;
wc->contextPtr->txMode = wc2->contextPtr->txMode;
wc->contextPtr->txSize = wc2->contextPtr->txSize;
wc->contextPtr->spExtra = wc2->contextPtr->spExtra;
wc->contextPtr->fgColor = wc2->contextPtr->fgColor;
wc->contextPtr->bgColor = wc2->contextPtr->bgColor;
wc->clipx = wc2->clipx;
wc->clipy = wc2->clipy;
wc->clipw = wc2->clipw;
wc->cliph = wc2->cliph;
wc->font = wc2->font;
wc->dx = wc2->dx;
wc->dy = wc2->dy;
wc->fillstyle = wc2->fillstyle;
wc->drawop = wc2->drawop;
return wc;
}
/*
* drawrectangles
* Parameters - the window binding for output, an array of rectangle
* a count of the number of structures -> the number of
* rectangles
*/
void drawrectangles(wbp wb, XRectangle *recs, int nrecs)
{
int i;
Rect r;
STDLOCALS (wb);
SetPort (ws->theWindow);
COPYCONTEXT (wc->contextPtr);
for (i = 0; i < nrecs; i++)
{
SetRect (&r, recs[i].x - 1,
recs[i].y - 1,
recs[i].x - 1 + recs[i].width,
recs[i].y - 1 + recs[i].height);
FrameRect (&r);
}
/*begin quote*/
PREPAREGWORLD (ws);
COPYCONTEXT (wc->contextPtr);
for (i = 0; i < nrecs; i++)
{
SetRect (&r, recs[i].x - 1,
recs[i].y - 1,
recs[i].x - 1 + recs[i].width,
recs[i].y - 1 + recs[i].height);
FrameRect (&r);
}
UnlockPixels (ws->offScreenPMHandle);
SetGWorld (ws->origPort, ws->origDev);
/*end quote*/
}
/*
* drawpoints() -
* Parameters - the window binding for output, an array of points (assumed
* to be fixed up for bitmap) and the number of points
*/
void drawpoints(wbinding *wb, XPoint *points, int npoints)
{
int i;
STDLOCALS (wb);
SetPort (ws->theWindow);
COPYCONTEXT(wc->contextPtr);
for (i = 0; i < npoints; i++) {
MoveTo (points[i].x-1, points[i].y-1);
LineTo (points[i].x-1, points[i].y-1);
}
/*begin quote*/
PREPAREGWORLD (ws);
COPYCONTEXT (wc->contextPtr);
for (i = 0; i < npoints; i++) {
MoveTo (points[i].x-1, points[i].y-1);
LineTo (points[i].x-1, points[i].y-1);
}
UnlockPixels (ws->offScreenPMHandle);
SetGWorld (ws->origPort, ws->origDev);
/*end quote*/
}
/*
* drawlines -
*/
void drawlines(wbinding *wb, XPoint *points, int npoints)
{
int i;
STDLOCALS (wb);
SetPort (ws->theWindow);
COPYCONTEXT (wc->contextPtr);
for (i = 0; i < (npoints - 1); i++)
{
MoveTo (points[i].x - 1, points[i].y - 1);
LineTo (points[i+1].x - 1, points[i+1].y - 1);
}
/*begin quote*/
PREPAREGWORLD (ws);
COPYCONTEXT (wc->contextPtr);
for (i = 0; i < (npoints - 1); i++)
{
MoveTo (points[i].x - 1, points[i].y - 1);
LineTo (points[i+1].x - 1, points[i+1].y - 1);
}
UnlockPixels (ws->offScreenPMHandle);
SetGWorld (ws->origPort, ws->origDev);
/*end quote*/
}
/*
* drawsegments() -
*/
void drawsegments(wbinding *wb, XSegment *segs, int nsegs)
{
int i;
STDLOCALS (wb);
SetPort (ws->theWindow);
COPYCONTEXT (wc->contextPtr);
for (i = 0; i < nsegs; i++)
{
MoveTo (segs[i].x1 - 1, segs[i].y1 - 1);
LineTo (segs[i].x2 - 1, segs[i].y2 - 1);
}
/*begin quote*/
PREPAREGWORLD (ws);
COPYCONTEXT (wc->contextPtr);
for (i = 0; i < nsegs; i++)
{
MoveTo (segs[i].x1 - 1, segs[i].y1 - 1);
LineTo (segs[i].x2 - 1, segs[i].y2 - 1);
}
UnlockPixels (ws->offScreenPMHandle);
SetGWorld (ws->origPort, ws->origDev);
/*end quote*/
}
/*
* drawarcs() - assumes x and y are already fixed up for the bitmap
*/
void drawarcs(wbinding *wb, XArc *arcs, int narcs)
{
int i;
Rect r;
STDLOCALS (wb);
SetPort (ws->theWindow);
COPYCONTEXT (wc->contextPtr);
for (i = 0; i < narcs; i++)
{
SetRect (&r, arcs[i].x - 1,
arcs[i].y - 1,
arcs[i].x - 1 + arcs[i].width,
arcs[i].y - 1 + arcs[i].height);
/* converts xarc spec to mac arc apec then pass it to FrameArc */
FrameArc (&r, (360 - arcs[i].angle1*64 + 90), arcs[i].angle2*64 * -1);
}
/*begin quote*/
PREPAREGWORLD (ws);
COPYCONTEXT (wc->contextPtr);
for (i = 0; i < narcs; i++)
{
SetRect (&r, arcs[i].x - 1,
arcs[i].y - 1,
arcs[i].x - 1 + arcs[i].width,
arcs[i].y - 1 + arcs[i].height);
FrameArc (&r, (360 - arcs[i].angle1*64 + 90), arcs[i].angle2*64 * -1);
}
UnlockPixels (ws->offScreenPMHandle);
SetGWorld (ws->origPort, ws->origDev);
/*end quote*/
}
/*
* fillarcs
*/
void fillarcs(wbp wb, XArc *arcs, int narcs)
{
int i;
Rect r;
STDLOCALS (wb);
SetPort (ws->theWindow);
COPYCONTEXT (wc->contextPtr);
for (i = 0; i < narcs; i++)
{
SetRect (&r, arcs[i].x - 1,
arcs[i].y - 1,
arcs[i].x - 1 + arcs[i].width,
arcs[i].y - 1 + arcs[i].height);
/* converts xarc spec to mac arc apec then pass it to FrameArc */
FillArc (&r, (360 - arcs[i].angle1*64 + 90), arcs[i].angle2*64 * -1,
&wc->contextPtr->fillPat);
}
/*begin quote*/
PREPAREGWORLD (ws);
COPYCONTEXT (wc->contextPtr);
for (i = 0; i < narcs; i++)
{
SetRect (&r, arcs[i].x - 1,
arcs[i].y - 1,
arcs[i].x - 1 + arcs[i].width,
arcs[i].y - 1 + arcs[i].height);
FillArc (&r, (360 - arcs[i].angle1*64 + 90), arcs[i].angle2*64 * -1,
&wc->contextPtr->fillPat);
}
UnlockPixels (ws->offScreenPMHandle);
SetGWorld (ws->origPort, ws->origDev);
/*end quote*/
}
/*
* fillpolygon
*/
void fillpolygon(wbp wb, XPoint *pts, int npts)
{
PolyHandle myPoly;
int i;
STDLOCALS (wb);
myPoly = OpenPoly ();
MoveTo (pts[0].x, pts[0].y);
for (i = 1; i < npts; i++)
{
LineTo (pts[i].x, pts[i].y);
}
MoveTo (pts[0].x, pts[0].y);
ClosePoly ();
SetPort (ws->theWindow);
COPYCONTEXT (wc->contextPtr);
FillPoly (myPoly, &wc->contextPtr->fillPat);
/*begin quote*/
PREPAREGWORLD (ws);
COPYCONTEXT (wc->contextPtr);
FillPoly (myPoly, &wc->contextPtr->fillPat);
UnlockPixels (ws->offScreenPMHandle);
SetGWorld (ws->origPort, ws->origDev);
/*end quote*/
KillPoly (myPoly);
}
/*
* fillrectangles
* Parameters - the window binding for output, an array of rectangle
* structures (assumed to be fixed up for the bitmap),
* a count of the number of structures -> the number of
* rectangles
*/
void fillrectangles(wbp wb, XRectangle *recs, int nrecs)
{
int i;
Rect r;
STDLOCALS (wb);
SetPort (ws->theWindow);
COPYCONTEXT (wc->contextPtr);
for (i = 0; i < nrecs; i++)
{
SetRect (&r, recs[i].x - 1,
recs[i].y - 1,
recs[i].x - 1 + recs[i].width,
recs[i].y - 1 + recs[i].height);
PaintRect (&r);
}
/*begin quote*/
PREPAREGWORLD (ws);
COPYCONTEXT (wc->contextPtr);
for (i = 0; i < nrecs; i++)
{
SetRect (&r, recs[i].x - 1,
recs[i].y - 1,
recs[i].x - 1 + recs[i].width,
recs[i].y - 1 + recs[i].height);
PaintRect (&r);
}
UnlockPixels (ws->offScreenPMHandle);
SetGWorld (ws->origPort, ws->origDev);
/*end quote*/
}
void UpdateCursorPos(wsp ws, wcp wc)
{
wc->contextPtr->pnLoc.h = ws->x;
wc->contextPtr->pnLoc.v = ws->y;
SetPort (ws->theWindow);
MoveTo (ws->x, ws->y);
}
int SetPattern (wbp w, char *name, int len)
{
}
/*
* Event processing
*/
int pollevent ()
{
GetEvents ();
return 400;
}
void GetEvents ()
{
EventRecord event;
Boolean done;
struct descrip d;
int eventCode = 0;
Point newMouseLoc;
done = false;
while (!done) {
if (WaitNextEvent (everyEvent, &event, kSleep, nil))
DoEvent (&event);
else {
if (gMouseInfo.wasDown) {
if (StillDown ()) {
GetMouse (&newMouseLoc);
if ((newMouseLoc.h != gMouseInfo.where.h) || (newMouseLoc.v != gMouseInfo.where.v)) {
gMouseInfo.when = TickCount ();
gMouseInfo.where = newMouseLoc;
switch (gMouseInfo.whichButton) {
case MOUSELEFT:
eventCode = MOUSELEFTDRAG;
break;
case MOUSEMID:
eventCode = MOUSEMIDDRAG;
break;
case MOUSERIGHT:
eventCode = MOUSERIGHTDRAG;
break;
}
MakeInt (eventCode, &d);
qevent (gMouseInfo.ws, &d,
gMouseInfo.where.h, gMouseInfo.where.v,
gMouseInfo.when, gMouseInfo.modKey);
} /* if (newMouseLoc ...) */
} /* if (StillDown ...) */
else {
gMouseInfo.wasDown = false;
}
} /* if (wasDown ...) */
done = true;
}
}
}
void DoEvent (EventRecord *eventPtr)
{
char theChar;
Boolean becomingActive;
switch (eventPtr->what) {
case mouseDown:
DoMouseDown (eventPtr);
break;
case mouseUp:
DoMouseUp (eventPtr);
break;
case autoKey:
case keyDown:
theChar = eventPtr->message & charCodeMask;
if ( (eventPtr->modifiers & cmdKey) != 0)
HandleMenuChoice (MenuKey (theChar));
else
DoKey (eventPtr, FrontWindow ());
break;
case updateEvt:
DoUpdate (eventPtr);
break;
case activateEvt:
becomingActive = ( (eventPtr->modifiers & activeFlag) == activeFlag);
DoActivate ( (WindowPtr)eventPtr->message, becomingActive);
break;
}
}
void DoMouseUp (EventRecord *eventPtr)
{
WindowPtr whichWindow;
short thePart;
int eventCode = 0;
int modKey = 0;
struct descrip d;
wbp wb;
wsp ws;
thePart = FindWindow (eventPtr->where, &whichWindow);
if (thePart == inContent) {
SelectWindow (whichWindow);
if ( ((eventPtr->modifiers & cmdKey) != 0) && ((eventPtr->modifiers & optionKey) ==0) )
eventCode = MOUSERIGHTUP;
if ( ((eventPtr->modifiers & optionKey) !=0) && ((eventPtr->modifiers & cmdKey) == 0) )
eventCode = MOUSEMIDUP;
if ( ((eventPtr->modifiers & optionKey) ==0) && ((eventPtr->modifiers & cmdKey) == 0) )
eventCode = MOUSELEFTUP;
MakeInt(eventCode,&d);
if ((eventPtr->modifiers & controlKey)!=0) modKey |= ControlMask;
if ((eventPtr->modifiers & shiftKey)!=0) modKey |= ShiftMask;
if ((eventPtr->modifiers & optionKey)!=0) modKey |= Mod1Mask;
for (wb = wbndngs; wb; wb = wb->next) {
ws = wb->window;
if (ws->theWindow == whichWindow) {
qevent(ws, &d,
eventPtr->where.h, eventPtr->where.v,
(uword)(eventPtr->when), modKey);
}
}
}
}
void DoMouseDown (EventRecord *eventPtr)
{
WindowPtr whichWindow;
short thePart;
long menuChoice;
int eventCode = 0;
int modKey = 0;
struct descrip d;
wbp wb;
wsp ws;
Point newMouseLoc;
thePart = FindWindow (eventPtr->where, &whichWindow);
switch (thePart) {
case inGoAway:
DisposeWindow (whichWindow);
break;
case inMenuBar:
menuChoice = MenuSelect (eventPtr->where);
HandleMenuChoice (menuChoice);
break;
case inSysWindow:
SystemClick (eventPtr, whichWindow);
break;
case inDrag:
DragWindow (whichWindow, eventPtr->where, &qd.screenBits.bounds);
break;
case inGrow:
DoGrowWindow (eventPtr, whichWindow);
break;
case inContent:
SelectWindow (whichWindow);
SetPort (whichWindow);
GlobalToLocal (&eventPtr->where);
/* left = click
mid = option-click
right = command-click */
if ( ((eventPtr->modifiers & cmdKey) != 0) && ((eventPtr->modifiers & optionKey) ==0) )
eventCode = MOUSERIGHT;
if ( ((eventPtr->modifiers & optionKey) !=0) && ((eventPtr->modifiers & cmdKey) == 0) )
eventCode = MOUSEMID;
if ( ((eventPtr->modifiers & optionKey) ==0) && ((eventPtr->modifiers & cmdKey) == 0) )
eventCode = MOUSELEFT;
MakeInt(eventCode,&d);
if ((eventPtr->modifiers & controlKey)!=0) modKey |= ControlMask;
if ((eventPtr->modifiers & shiftKey)!=0) modKey |= ShiftMask;
if ((eventPtr->modifiers & optionKey)!=0) modKey |= Mod1Mask;
for (wb = wbndngs; wb; wb = wb->next) {
ws = wb->window;
if (ws->theWindow == whichWindow) {
qevent(ws, &d,
eventPtr->where.h, eventPtr->where.v,
(uword)(eventPtr->when), modKey);
gMouseInfo.ws = ws;
break;
}
}
gMouseInfo.wasDown = true;
gMouseInfo.when = (uword)(eventPtr->when);
gMouseInfo.where = eventPtr->where;
gMouseInfo.modKey = modKey;
gMouseInfo.whichButton = eventCode;
}
}
void DoKey (EventRecord *eventPtr, WindowPtr whichWindow)
{
char theChar;
int modKey = 0;
wbp wb;
wsp ws;
struct descrip d;
if (whichWindow == nil) return;
modKey = 0;
theChar = eventPtr->message & charCodeMask;
StrLen(d) = 1;
StrLoc(d) = (char *)&allchars[theChar];
if ((eventPtr->modifiers & controlKey)!=0) modKey |= ControlMask;
if ((eventPtr->modifiers & shiftKey)!=0) modKey |= ShiftMask;
if ((eventPtr->modifiers & optionKey)!=0) modKey |= Mod1Mask;
for (wb = wbndngs; wb; wb = wb->next) {
ws = wb->window;
if (ws->theWindow == whichWindow) {
qevent(ws, &d,
wb->context->contextPtr->pnLoc.h,
wb->context->contextPtr->pnLoc.v,
(uword)(eventPtr->when), modKey);
}
}
}
void DoGrowWindow (EventRecord *eventPtr, WindowPtr whichWindow)
{
long growSize;
Rect limitRect;
wbp wb;
wsp ws;
wcp wc;
RgnHandle locUpdateRgn;
SetRect (&limitRect, kMinDocSize, kMinDocSize, kMaxDocSize, kMaxDocSize);
growSize = GrowWindow (whichWindow, eventPtr->where, &limitRect);
if (growSize != 0) {
for (wb = wbndngs; wb; wb = wb->next) {
ws = wb->window;
wc = wb->context;
if (ws->theWindow == whichWindow) {
SizeWindow (whichWindow, LoWord(growSize), HiWord(growSize), true);
InvalRect (&(ws->theWindow->portRect));
return;
}
}
}
}
void GetLocUpdateRgn (WindowPtr whichWindow, RgnHandle localRgn)
{
CopyRgn (((WindowPeek)(whichWindow))->updateRgn, localRgn);
OffsetRgn (localRgn, whichWindow->portBits.bounds.left, whichWindow->portBits.bounds.top);
}
void HandleMenuChoice (long menuChoice)
{
short menu;
short item;
if (menuChoice != 0) {
menu = HiWord (menuChoice);
item = LoWord (menuChoice);
switch (menu) {
case kAppleMenu:
HandleAppleChoice (item);
break;
case kFileMenu:
HandleFileChoice (item);
break;
case kOptionsMenu:
HandleOptionsChoice (item);
break;
}
HiliteMenu (0);
}
}
void HandleAppleChoice (short item)
{
MenuHandle appleMenu;
Str255 accName;
short accNumber;
switch (item) {
case kAboutMItem:
SysBeep (20);
break;
/* ******************* open a dialog box **************** */
default:
appleMenu = GetMHandle (kAppleMenu);
GetItem (appleMenu, item, accName);
accNumber = OpenDeskAcc (accName);
break;
}
}
void HandleFileChoice (short item)
{
StandardFileReply fileReply;
SFTypeList typeList;
short numTypes;
char *fileName;
int argc;
char *argv[kNARGS+1];
char buf[256];
char *tmpStr;
MenuHandle menu;
switch (item) {
case kQuitMItem:
abort ();
break;
case kRunMItem:
typeList[0] = 'ICOD';
numTypes = 1;
StandardGetFile (nil, numTypes, typeList, &fileReply);
if (fileReply.sfGood) {
fileName = PtoCstr (fileReply.sfFile.name);
menu = GetMHandle (kFileMenu);
DisableItem (menu, kRunMItem);
menu = GetMHandle (kOptionsMenu);
DisableItem (menu, 0);
textHandle = GetString(kStringID);
HLock((Handle)textHandle);
SetString (textHandle, "\p");
HUnlock((Handle)textHandle);
ChangedResource((Handle)textHandle);
WriteResource((Handle)textHandle);
}
else
break;
tmpStr = malloc (strlen ("ICONX ") + strlen (fileName) + 1 + strlen (cmlArgs) + 1);
strcpy (tmpStr, "ICONX ");
strcat (tmpStr, fileName);
strcat (tmpStr, " ");
strcat (tmpStr, cmlArgs);
sprintf (buf, "%#s", tmpStr);
argc = ParseCmdLineStr (buf, tmpStr, argv);
MacMain (argc, argv);
break;
}
}
void HandleOptionsChoice (short item)
{
StandardFileReply fileReply;
SFTypeList typeList;
short numTypes;
char *fileName;
DialogPtr dialog;
Boolean dialogDone;
short itemHit, itemType;
Handle okItemHandle, textItemHandle;
Rect itemRect;
char *tmpStr;
Str255 itemText;
switch (item) {
case kRInMItem:
typeList[0] = 'TEXT';
numTypes = 1;
StandardGetFile (nil, numTypes, typeList, &fileReply);
if (fileReply.sfGood) {
fileName = PtoCstr (fileReply.sfFile.name);
k_input.fd = fopen (fileName, "r");
/*
StrLen (k_input.fname) = strlen (fileName) + 1;
*/
}
break;
case kROutMItem:
StandardPutFile ("\pSave output file as:", "\poutput.txt", &fileReply);
if (fileReply.sfGood) {
fileName = PtoCstr (fileReply.sfFile.name);
/*
setfile (fileName, 'TEXT', 'ttxt');
*/
k_output.fd = freopen (fileName, "w", stdout);
StrLen (k_output.fname) = strlen (fileName) + 1;
}
break;
case kArgsMItem:
dialogDone = false;
dialog = GetNewDialog (kCLArgsDialog, nil, kMoveToFront);
GetDItem (dialog, kArgStringField, &itemType, &textItemHandle, &itemRect);
GetDItem (dialog, ok, &itemType, &okItemHandle, &itemRect);
textHandle = GetString (kStringID);
HLock ((Handle) textHandle);
SetIText (textItemHandle, *textHandle);
HUnlock ((Handle) textHandle);
SelIText (dialog, kArgStringField, 0, 32767);
ShowWindow (dialog);
SetPort (dialog);
SetDialogDefaultItem (dialog, ok);
SetDialogCancelItem (dialog, cancel);
SetDialogTracksCursor (dialog, true);
while (!dialogDone) {
GetIText (textItemHandle, itemText);
if (itemText [0] == 0)
HiliteControl ((ControlHandle)okItemHandle, kDisableButton);
else
HiliteControl ((ControlHandle)okItemHandle, kEnableButton);
ModalDialog (nil, &itemHit);
dialogDone = ((itemHit == ok) || (itemHit == cancel));
}
if (itemHit == ok) {
GetIText (textItemHandle, itemText);
SetHandleSize ((Handle) textHandle, (Size) (itemText[0] + 1));
HLock ((Handle) textHandle);
GetIText (textItemHandle, *textHandle);
HUnlock ((Handle) textHandle);
ChangedResource ((Handle) textHandle);
WriteResource ((Handle) textHandle);
tmpStr = PtoCstr (itemText);
cmlArgs = malloc (strlen (tmpStr) + 1);
strcpy (cmlArgs, tmpStr);
DisposeDialog (dialog);
}
else {
DisposeDialog (dialog);
}
break;
}
}
void DoUpdate (EventRecord *eventPtr)
{
WindowPtr whichWindow;
whichWindow = (WindowPtr)eventPtr->message;
BeginUpdate (whichWindow);
RedrawWindow (whichWindow);
EndUpdate (whichWindow);
}
void DoActivate (WindowPtr whichWindow, Boolean becomingActive)
{
}
void RedrawWindow (WindowPtr whichWindow)
{
wsp ws;
wcp wc;
wbp wb;
GWorldFlags updateOK;
for (wb = wbndngs; wb; wb = wb->next) {
ws = wb->window;
wc = wb->context;
if (ws->theWindow == whichWindow) {
updateOK = UpdateGWorld(&(ws->offScreenGWorld), 8, &(ws->GWorldRect), nil, nil, 0);
SetPort(ws->theWindow);
EraseRect(&(ws->theWindow->portRect));
ws->sourceRect=ws->theWindow->portRect;
ws->destRect=ws->theWindow->portRect;
ws->lockOK = LockPixels (ws->offScreenPMHandle);
CopyBits(&(((GrafPtr)(ws->offScreenGWorld))->portBits),
&(((GrafPtr)(ws->theWindow))->portBits),
&(ws->sourceRect),&(ws->destRect),transparent, nil);
UnlockPixels(ws->offScreenPMHandle);
}
}
}
static int ParseCmdLineStr(char *s, char *t, char **argv)
{
int c, quote = 0, argc = 0;
while (c = *s++) {
if (c == ' ')
continue;
if (argc < kNARGS)
argv[argc++] = t;
do {
if (c == '\\' && *s)
c = *s++;
else if (c == '"' || c == '\'') {
if (!quote) {
quote = c;
continue;
}
if (c == quote) {
quote = 0;
continue;
}
}
*t++ = c;
} while (*s && ((c = *s++) != ' ' || quote));
*t++ = 0;
}
return(argc);
}
/*
void setfile(filename,type,creator)
char *filename;
OSType type,creator;
{
FInfo info;
if (getfinfo(filename,0,&info) == 0) {
info.fdType = type;
info.fdCreator = creator;
setfinfo(filename,0,&info);
}
return;
}
*/