diff --git a/doc/ib/appH.tex b/doc/ib/appH.tex index 051dbdceb..e5d9b27a5 100644 --- a/doc/ib/appH.tex +++ b/doc/ib/appH.tex @@ -271,8 +271,8 @@ \chapter{Glossary of Defined Symbols} LONG64 & IU & C compiler's long is 64 bits (xpm) \\ LoopThreshold & U & number of tended var initializations iconc will unroll \\ M\_PI & IU & constant value of Pi \\ -MacGraph & U & build graphics using (legacy pre OSX) Mac graphics (should delete) \\ -MACGRAPH\_H & IU & macgraph.h has been included \\ +{\gr MacGraph} & {\gr U} &{\gr build graphics using (legacy pre OSX) Mac graphics (should delete)} \\ +{\gr MACGRAPH\_H} & {\gr IU} & {\gr macgraph.h has been included} \\ {\gr MACINTOSH} & {\gr all} & {\gr build on legacy Mac platform (delete?)} \\ MacOS & U & build on modern UNIX-based Mac platform \\ max & all & compute maximum of x and y \\ diff --git a/src/h/config.h b/src/h/config.h index 20ef568da..8c540b4bc 100644 --- a/src/h/config.h +++ b/src/h/config.h @@ -428,15 +428,8 @@ #define ConsoleWindow 1 #endif /* NTConsole */ #endif /* MSWindows */ - - #ifdef MacGraph - #undef Graphics - #define Graphics 1 - #endif /* MacGraph */ #endif - - #ifdef Graphics #ifndef NoXpmFormat #if UNIX @@ -446,10 +439,8 @@ #endif /* NoXpmFormat */ #ifndef MSWindows - #ifndef MacGraph - #undef XWindows - #define XWindows 1 - #endif /* MacGraph */ + #undef XWindows + #define XWindows 1 #endif /* MSWindows */ #undef LineCodes @@ -1026,3 +1017,7 @@ Deliberate Syntax Error #if defined(MACINTOSH) #error The MACINTOSH configuration option is no longer supported (since 7 Mar 2024) #endif /* MACINTOSH */ + +#if defined(MacGraph) +#error The MacGraph configuration option is no longer supported (since 8 Mar 2024) +#endif /* MacGraph */ diff --git a/src/h/graphics.h b/src/h/graphics.h index 8347f1c26..56955e067 100644 --- a/src/h/graphics.h +++ b/src/h/graphics.h @@ -4,10 +4,6 @@ #define MAXDISPLAYNAME 128 -#ifdef MacGraph - #include "::h:macgraph.h" -#endif /* MacGraph */ - #ifdef XWindows #include "../h/xwin.h" #endif /* XWindows */ @@ -241,12 +237,6 @@ typedef struct _wfont { char type; int size; void *fonts; -#ifdef MacGraph - short fontNum; - Style fontStyle; - int fontSize; - FontInfo fInfo; /* I-173 */ -#endif /* MacGraph */ #ifdef XWindows char * name; /* name for WAttrib and fontsearch */ int ascent; /* font dimensions */ @@ -323,25 +313,6 @@ struct imgmem { #define PCH2 ',' /* punctuation character */ -#ifdef MacGraph -typedef struct _wctype { - Pattern bkPat; - Pattern fillPat; - Point pnLoc; - Point pnSize; - short pnMode; - Pattern pnPat; - short txFont; - Style txFace; - short txMode; - short txSize; - Fixed spExtra; - RGBColor fgColor; - RGBColor bgColor; -} ContextType, *ContextPtrType; -#endif /* MacGraph */ - - /* * Texture management requires that we be able to lookup and reuse * existing textures, as well as support dynamic window-based textures. @@ -460,9 +431,6 @@ typedef struct _wcontext { int leading; /* inter-line leading */ #endif /* GraphicsGL */ -#ifdef MacGraph - ContextPtrType contextPtr; -#endif /* MacGraph */ wdp display; #ifdef XWindows GC gc; /* X graphics context */ @@ -598,19 +566,6 @@ typedef struct _wstate { struct descrip filep, listp; /* icon values for this window */ struct wbind_list *children; struct _wbinding *parent; -#ifdef MacGraph - WindowPtr theWindow; /* pointer to the window */ - PicHandle windowPic; /* handle to backing pixmap */ - GWorldPtr offScreenGWorld; /* offscreen graphics world */ - CGrafPtr origPort; - GDHandle origDev; - PixMapHandle offScreenPMHandle; - Rect sourceRect; - Rect destRect; - Rect GWorldRect; - Boolean lockOK; - Boolean visible; -#endif /* MacGraph */ wdp display; #ifdef GraphicsGL @@ -708,20 +663,6 @@ struct wbind_list { struct wbind_list *next; }; -#ifdef MacGraph -typedef struct - { - Boolean wasDown; - uword when; - Point where; - int whichButton; - int modKey; - wsp ws; - } MouseInfoType; -#endif /* MacGraph */ - - - /* * Gamma Correction value to compensate for nonlinear monitor color response */ diff --git a/src/h/grttin.h b/src/h/grttin.h index 94cc9fa77..a59b3fc49 100644 --- a/src/h/grttin.h +++ b/src/h/grttin.h @@ -394,15 +394,6 @@ typedef int va_list, siptr; #endif /* HAVE_LIBFREETYPE */ #endif /* GraphicsGL */ - #ifdef MacGraph - typedef int Str255, Point, StandardFileReply, SFTypeList, Ptr, PixMap; - typedef int Boolean, Rect, PolyHandle, EventRecord, wsp, MouseInfoType; - typedef int Handle, MenuHandle, OSErr, WindowPtr, GWorldFlags; - typedef int PaletteHandle, BitMap, RgnHandle, QDErr, GWorldPtr; - typedef int GrafPtr, GDHandle, PixMapHandle, OSType, FInfo; - typedef int IOParam, DialogPtr, ControlHandle, StringHandle, Size; - #endif /* MacGraph */ - #ifdef XWindows typedef int Atom, Time, XSelectionEvent, XErrorEvent, XErrorHandler; typedef int XGCValues, XColor, XFontStruct, XWindowAttributes, XEvent; diff --git a/src/h/macgraph.h b/src/h/macgraph.h deleted file mode 100644 index 4b17d66d2..000000000 --- a/src/h/macgraph.h +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Constants - */ -#include - -#define kEmptyString "\p" -#define kMoveToFront (WindowPtr)-1L -#define kVisible true -#define kInvisible false -#define kHasGoAway true -#define kNilRefCon (long)nil -#define kPi 3.14159265358979323846264338327950288419716939937511 -#define kSleep 400 - -#define kMenuBar 128 - -#define kAppleMenu 128 -#define kAboutMItem 1 - -#define kFileMenu 129 -#define kCompileMItem 1 -#define kRunMItem 1 -#define kQuitMItem 3 - -#define kOptionsMenu 130 -#define k_cMItem 1 -#define kRInMItem 1 -#define kROutMItem 2 -#define kArgsMItem 3 -#define kEchoOut2Con 5 - -#define kCLArgsDialog 128 -#define kArgStringField 3 - -#define kDisableButton 255 -#define kEnableButton 0 - -#define kStringID 128 -#define kNARGS 25 - -#define kMinDocSize 64 -#define kMaxDocSize 500 -#define kZeroTolerance 0x0000 - -#define DMAXCOLORS 256 -#define FS_SOLID 1 -#define FS_STIPPLE 2 -#define FS_OPAQUESTIPPLE 4 - - -/* - * Macros - */ - -#define STDLOCALS(wb) wcp wc=(wb)->context;\ - wsp ws=(wb)->window;\ - WindowPtr stdwin=ws->theWindow - -#define ICONFILENAME(wb) ((wb)->window->iconimage) -#define ICONLABEL(wb) ((wb)->window->iconlabel) -#define WINDOWLABEL(wb) ((wb)->window->windowlabel) - -#define ANGLE(ang) (ang) -#define EXTENT(ang) (ang) -#define RECX(recs) ((recs).x) -#define RECY(recs) ((recs).y) -#define RECWIDTH(recs) ((recs).width) -#define RECHEIGHT(recs) ((recs).height) - -#define FULLARC 360<<6 -#define ARCWIDTH(arc) ((arc).width) -#define ARCHEIGHT(arc) ((arc).height) - -#define RED(x) ((x).red) -#define GREEN(x) ((x).green) -#define BLUE(x) ((x).blue) - -#define ASCENT(wb) ((wb)->context->font->fInfo.ascent) -#define DESCENT(wb) ((wb)->context->font->fInfo.descent) -#define LEADING(wb) ((wb)->context->font->fInfo.leading) -#define FWIDTH(wb) ((wb)->context->font->fInfo.widMax) -#define FHEIGHT(wb) ( (ASCENT(wb))+(DESCENT(wb))+(LEADING(wb)) ) -#define MAXDESCENDER(wb) ((wb)->context->font->fInfo.descent) - -#define DISPLAYWIDTH(wb) (qd.screenBits.bounds.right-qd.screenBits.bounds.left) -#define DISPLAYHEIGHT(wb) (qd.screenBits.bounds.bottom-qd.screenBits.bounds.top) - -#define LINEWIDTH(wb) ((wb)->context->contextPtr->pnSize.h) -#define TEXTWIDTH(wb,s,n) ( TextWidth(s,(int)(s),n) ) - -#define SCREENDEPTH(wb) 8 - -#define COPYCONTEXT(c) BackPat(&(c)->bkPat);\ - MoveTo((c)->pnLoc.h,(c)->pnLoc.v);\ - PenSize((c)->pnSize.h,(c)->pnSize.v);\ - PenMode((c)->pnMode);\ - PenPat(&(c)->pnPat);\ - TextFont((c)->txFont);\ - TextFace((c)->txFace);\ - TextMode((c)->txMode);\ - TextSize((c)->txSize);\ - SpaceExtra((c)->spExtra) - -#define SETCONTEXTDEFAULT(c) memcpy(&((c)->bkPat),&qd.white,sizeof(Pattern));\ - memcpy(&((c)->fillPat),&qd.black,sizeof(Pattern));\ - (c)->pnLoc.h=0;(c)->pnLoc.v=0;\ - (c)->pnSize.h=1;(c)->pnSize.v=1;\ - (c)->pnMode=patCopy;\ - memcpy(&((c)->pnPat),&qd.black,sizeof(Pattern));\ - (c)->txFont=0;\ - (c)->txFace=normal;\ - (c)->txMode=srcOr;\ - (c)->txSize=0;\ - (c)->spExtra=0;\ - (c)->fgColor.red=0;\ - (c)->fgColor.green=0;\ - (c)->fgColor.blue=0;\ - (c)->bgColor.red=65535;\ - (c)->bgColor.green=65535;\ - (c)->bgColor.blue=65535 - -#define PREPAREGWORLD(ws) GetGWorld(&((ws)->origPort),&((ws)->origDev));\ - SetGWorld((ws)->offScreenGWorld,nil);\ - (ws)->offScreenPMHandle=GetGWorldPixMap((ws)->offScreenGWorld);\ - (ws)->lockOK=LockPixels((ws)->offScreenPMHandle) - -#define GWORLD2WINDOW(ws) (ws)->sourceRect=(ws)->theWindow->portRect;\ - (ws)->sourceRect.bottom=(ws)->theWindow->portRect.bottom;\ - (ws)->sourceRect.right=(ws)->theWindow->portRect.right;\ - (ws)->destRect=(ws)->theWindow->portRect;\ - (ws)->destRect.bottom=(ws)->theWindow->portRect.bottom;\ - (ws)->destRect.right=(ws)->theWindow->portRect.right;\ - CopyBits(&(((GrafPtr)((ws)->offScreenGWorld))->portBits),\ - &(((GrafPtr)((ws)->theWindow))->portBits),\ - &((ws)->sourceRect),&((ws)->destRect),srcCopy,\ - nil);\ - UnlockPixels((ws)->offScreenPMHandle);\ - SetGWorld((ws)->origPort,(ws)->origDev) - -#define EVQUEGET(ws,d) {\ - int i;\ - if (!c_get((struct b_list *)BlkLoc((ws)->listp),&d)) fatalerr(0,NULL);\ - if (Qual(d)) {\ - ws->eventQueue[(ws)->eQfront++] = *StrLoc(d);\ - if ((ws)->eQfront >= EQUEUELEN) (ws)->eQfront = 0;\ - (ws)->eQback = (ws)->eQfront;\ - }\ - } - -#define EVQUEEMPTY(ws) (BlkLoc((ws)->listp)->list.size == 0) - -/* - * the bitmasks for the modifier keys - */ -#ifndef MACGRAPH_H -#define MACGRAPH_H - -#define ControlMask (1 << 16) -#define Mod1Mask (2 << 16) -#define ShiftMask (4 << 16) - -/* - * macros performing row/column to pixel y,x translations - * computation is 1-based and depends on the current font's size. - * exception: XTOCOL as defined is 0-based, because that's what its - * clients seem to need. - */ - -#define MARGIN 0 - -#define ROWTOY(wb,row) ((row-1) * LEADING(wb) + ASCENT(wb) + MARGIN) -#define COLTOX(wb,col) ((col-1) * FWIDTH(wb) + MARGIN) -#define YTOROW(wb,y) (((y) - MARGIN) / LEADING(wb) + 1) -#define XTOCOL(wb,x) (!FWIDTH(wb) ? ((x)-MARGIN) : (((x) - MARGIN) / FWIDTH(wb))) - -/* - * typedef & structs - */ - -typedef struct - { - long x, y; - long width, height; - long angle1, angle2; - } XArc; - -typedef struct - { - long x,y; - } XPoint; - -typedef struct - { - long x1, y1; - long x2, y2; - } XSegment; - -typedef struct - { - long x, y; - long width, height; - } XRectangle; - -#endif /* MACGRAPH_H */ diff --git a/src/h/rproto.h b/src/h/rproto.h index d47b36a71..c28e0d026 100644 --- a/src/h/rproto.h +++ b/src/h/rproto.h @@ -668,45 +668,6 @@ int checkOpenConsole( FILE *w, char *s ); int Consolefflush (FILE *file); #endif /* ConsoleWindow */ - #ifdef MacGraph - /* - * Implementation routines specific to Macintosh - */ - void hidecrsr (wsp ws); - void showcrsr (wsp ws); - void UpdateCursorPos(wsp ws, wcp wc); - void GetEvents (void); - void DoEvent (EventRecord *eventPtr); - void DoMouseUp (EventRecord *eventPtr); - void DoMouseDown (EventRecord *eventPtr); - void DoGrowWindow (EventRecord *eventPtr, WindowPtr whichWindow); - void GetLocUpdateRgn (WindowPtr whichWindow, RgnHandle localRgn); - void DoKey (EventRecord *eventPtr, WindowPtr whichWindow); - void EventLoop(void); - void HandleMenuChoice (long menuChoice); - void HandleAppleChoice (short item); - void HandleFileChoice (short item); - void HandleOptionsChoice (short item); - void DoUpdate (EventRecord *eventPtr); - void DoActivate (WindowPtr whichWindow, Boolean becomingActive); - void RedrawWindow (WindowPtr whichWindow); - const int ParseCmdLineStr (char *s, char *t, char **argv); - pascal OSErr SetDialogDefaultItem (DialogPtr theDialog, short newItem) = - { 0x303C, 0x0304, 0xAA68 }; - pascal OSErr SetDialogCancelItem (DialogPtr theDialog, short newItem) = - { 0x303C, 0x0305, 0xAA68 }; - pascal OSErr SetDialogTracksCursor (DialogPtr theDialog, Boolean tracks) = - { 0x303C, 0x0306, 0xAA68 }; - - void drawarcs(wbinding *wb, XArc *arcs, int narcs); - void drawlines(wbinding *wb, XPoint *points, int npoints); - void drawpoints(wbinding *wb, XPoint *points, int npoints); - void drawrectangles(wbp wb, XRectangle *recs, int nrecs); - void drawsegments(wbinding *wb, XSegment *segs, int nsegs); - void fillarcs(wbp wb, XArc *arcs, int narcs); - void fillpolygon(wbp wb, XPoint *pts, int npts); - #endif /* MacGraph */ - #ifdef XWindows /* * Implementation routines specific to X-Windows diff --git a/src/runtime/Makefile b/src/runtime/Makefile index 5878af7c8..21816fd9e 100644 --- a/src/runtime/Makefile +++ b/src/runtime/Makefile @@ -13,7 +13,7 @@ HDRS = ../h/define.h ../h/config.h ../h/typedefs.h ../h/monitor.h\ ../h/rproto.h ../h/mproto.h ../h/version.h ../h/sys.h GRAPHICSHDRS = ../h/graphics.h ../h/xwin.h -GRAPHICSRI = rmac.ri rxwin.ri rmswin.ri rwin3d.ri ropengl.ri rd3d.ri ropengl2d.ri +GRAPHICSRI = rxwin.ri rmswin.ri rwin3d.ri ropengl.ri rd3d.ri ropengl2d.ri .PHONY: update_rev diff --git a/src/runtime/imain.r b/src/runtime/imain.r index 735d0247c..180833750 100644 --- a/src/runtime/imain.r +++ b/src/runtime/imain.r @@ -22,14 +22,6 @@ */ void icon_setup (int argc, char **argv, int *ip); -#ifdef MacGraph -void MacMain (int argc, char **argv); -void ToolBoxInit (void); -void MenuBarInit (void); -void MouseInfoInit (void); -int GetArgs (char **argv); -#endif /* MacGraph */ - /* * The following code is operating-system dependent [@imain.01]. Declarations * that are system-dependent. @@ -134,16 +126,6 @@ void ExpandArgv(int *argcp, char ***avp) #endif /* WildCards */ #endif /* NT */ -#ifdef MacGraph -MouseInfoType gMouseInfo; -PaletteHandle gPal; -long gNumColors; -Boolean gDone; -char *cmlArgs; -StringHandle textHandle; - -void MacMain (int argc, char **argv) -#else /* MacGraph */ #ifdef DLLICONX #passthru void __declspec(dllexport) iconx_entry(int argc, char **argv) #else /* DLLICONX */ @@ -153,7 +135,6 @@ int main(int argc, char **argv) void main(int argc, char **argv) #endif /* INTMAIN */ #endif /* DLLICONX */ -#endif /* MacGraph */ { int i, slen; @@ -882,62 +863,3 @@ char *ArgvToCmdline(char **argv) return mytmp; } #endif /* NT */ - - -#ifdef MacGraph -void MouseInfoInit (void) -{ - gMouseInfo.wasDown = false; -} - -void ToolBoxInit (void) -{ - InitGraf (&qd.thePort); - InitFonts (); - InitWindows (); - InitMenus (); - TEInit (); - InitDialogs (nil); - InitCursor (); -} - -void MenuBarInit (void) -{ - Handle menuBar; - MenuHandle menu; - OSErr myErr; - long feature; - - menuBar = GetNewMBar (kMenuBar); - SetMenuBar (menuBar); - - menu = GetMHandle (kAppleMenu); - AddResMenu (menu, 'DRVR'); - - DrawMenuBar (); -} - -void EventLoop ( void ) -{ - EventRecord event, *eventPtr; - char theChar; - - gDone = false; - while ( gDone == false ) - { - if ( WaitNextEvent ( everyEvent, &event, kSleep, nil ) ) - DoEvent ( &event ); - } -} - -void main () -{ - atexit (EventLoop); - ToolBoxInit (); - MenuBarInit (); - MouseInfoInit (); - cmlArgs = ""; - - EventLoop (); -} -#endif /* MacGraph */ diff --git a/src/runtime/rmac.ri b/src/runtime/rmac.ri deleted file mode 100644 index e236d0f02..000000000 --- a/src/runtime/rmac.ri +++ /dev/null @@ -1,1048 +0,0 @@ -/* - * File: rmac.ri - Mac system-specific graphics interface code. - */ - -#ifdef Graphics - -#passthru #ifndef __QUICKDRAW__ -struct RGBColor { - unsigned short red; /*magnitude of red component*/ - unsigned short green; /*magnitude of green component*/ - unsigned short blue; /*magnitude of blue component*/ -}; -typedef struct RGBColor RGBColor, *RGBColorPtr, **RGBColorHdl; -#passthru #endif -#passthru #include - -/* - * Global variables specific to Mac - */ -extern PaletteHandle gPal; -extern long gNumColors; - -/* - * Prototypes - */ -int CreateWindow (wbp wb); -int seticonicstate (wbp w, char *s); -void unsetclip (wbp w); -int seticonpos (wbp w, char *s); -int setdisplay (wbp w, char *s); - -/* - * allocates a window binding, a context and a state, then calls - * CreateWindow to draw the window on screen - */ - -FILE *wopen(name, lp, attr, n, err_index) -char *name; -struct b_list *lp; -dptr attr; -int n, *err_index; - - { - wbp wb; - wsp ws; - wcp wc; - char dispchrs[256]; - char answer[128]; - char *display = NULL; - int i; - tended struct b_list *tlp; - tended struct descrip attrrslt; - - tlp = lp; - - for(i=0;i8) && - !strncmp("display=",StrLoc(attr[i]),8)) - { - strncpy(dispchrs,StrLoc(attr[i])+8,StrLen(attr[i])-8); - dispchrs [ StrLen(attr[i])-8 ] = '\0'; - display = dispchrs; - } - } - - - /* - * Allocate a binding, a state and a context - */ - - Protect(wb = alc_wbinding(), return NULL); - Protect(wb->window = alc_winstate(), { free_binding(wb); return NULL; }); - Protect(wb->context = alc_context(wb), { free_binding(wb); return NULL; }); - ws = wb->window; - ws->listp.dword = D_List; - BlkLoc(ws->listp) = (union block *)tlp; - wc = wb->context; - - /* - * Defaults - */ - ws->height = 100; - ws->width = 100; - ws->posy = 60; - ws->posx = 20; - ws->visible = kVisible; - - /* - * some window attributes - */ - - /* - * Loop through any remaining arguments. - */ - for (i = 0; i < n; i++) - { - /* - * write the attribute, - * except "display=" attribute, which is done earlier - */ - if((StrLen(attr[i])<9)||strncmp(StrLoc(attr[i]),"display=",8)) - { - switch (wattrib((wbp) wb, StrLoc(attr[i]), StrLen(attr[i]), &attrrslt, answer)) - { - case RunError: - *err_index = i; - return NULL; - case Failed: - free_binding((wbp)wb); - return NULL; - } - } - } - - - /* set window color according to context */ - - if (CreateWindow(wb) != 1) return NULL; - return (FILE *)wb; - } - -/* - * Creates a window and shows it on screen - */ - -int CreateWindow(wbp wb) - { - Rect winRect; - QDErr errGWorld; - STDLOCALS (wb); - - - - /* - * create the window - */ - - SetRect (&winRect, - ws->posx, ws->posy, - (ws->posx)+(ws->width), - (ws->posy)+(ws->height)); - - ws->theWindow = NewCWindow (nil, - &winRect, - "\pUntitled", - ws->visible, - documentProc, - kMoveToFront, - kHasGoAway, - kNilRefCon); - - /* - * creating offscreen graphics world - */ - - SetRect (&(ws->GWorldRect), 0, 0, kMaxDocSize, kMaxDocSize); - GetGWorld (&(ws->origPort), &(ws->origDev)); - errGWorld = NewGWorld (&(ws->offScreenGWorld), 0, &(ws->GWorldRect), nil, nil, 0); - if (errGWorld != noErr) - printf ("Cannot create offscreen graphics world!\n"); - SetGWorld (ws->offScreenGWorld, nil); - ws->offScreenPMHandle = GetGWorldPixMap (ws->offScreenGWorld); - ws->lockOK = LockPixels (ws->offScreenPMHandle); - EraseRect (&(ws->offScreenGWorld->portRect)); - UnlockPixels (ws->offScreenPMHandle); - SetGWorld (ws->origPort, ws->origDev); - - return 1; -} - -/* - * Draw a bilevel image - */ -int blimage(w, x, y, width, height, ch, s, len) -wbp w; -int x, y, width, height, ch; -unsigned char *s; -word len; -{ -} - -/* - * copy an area - */ -int copyArea(wb1,wb2,x,y,width,height,x2,y2) -wbp wb1, wb2; -int x, y, width, height, x2, y2; -{ - Rect sourceRect, destRect; - - SetRect (&sourceRect, x, y, x+width, y+height); - SetRect (&destRect, x2, y2, x2+width, y2+width); - - CopyBits (&(((GrafPtr)(wb1->window->theWindow))->portBits), - &(((GrafPtr)(wb2->window->theWindow))->portBits), - &sourceRect, &destRect, srcCopy, nil); - LockPixels (wb1->window->offScreenGWorld->portPixMap); - LockPixels (wb2->window->offScreenGWorld->portPixMap); - CopyBits (&(((GrafPtr)(wb1->window->offScreenGWorld))->portBits), - &(((GrafPtr)(wb2->window->offScreenGWorld))->portBits), - &sourceRect, &destRect, srcCopy, nil); - UnlockPixels (wb1->window->offScreenGWorld->portPixMap); - UnlockPixels (wb2->window->offScreenGWorld->portPixMap); -} - -/* - * clear an area - */ -void clearArea(w,x,y,width,height) -wbp w; -int x, y, width, height; -{ -} - -/* - * erase an area - */ -void eraseArea(wb, x, y, width, height) -wbp wb; -int x, y, width, height; -{ - Rect r; - STDLOCALS (wb); - - SetPort (ws->theWindow); - COPYCONTEXT (wc->contextPtr); - SetRect (&r, x - 1, - y - 1, - (width == 0) ? (ws->posx + ws->width) : (x - 1 + width), - (height == 0) ? (ws->posy + ws->height) : (y - 1 + height) ); - EraseRect (&r); - -/* */ - PREPAREGWORLD (ws); - COPYCONTEXT (wc->contextPtr); - EraseRect (&r); - UnlockPixels (ws->offScreenPMHandle); - SetGWorld (ws->origPort, ws->origDev); -/* */ -} - -/* - * dumpimage -- write an image to a disk file in an X format. - * - * Accepts only .xpm and .xbm file names, returning NoCvt for anything else. - */ - -int dumpimage(w,filename,x,y,width,height) -wbp w; -char *filename; -unsigned int x, y, height, width; -{ -} - -int do_config(w, status) -wbp w; -int status; -{ -} - -void free_rgb(w, rgb) -wbp w; -RGBColor *rgb; -{ -} - -void freecolor(w, s) -wbp w; -char s; -{ -} - -void geticonic(w, answer) -wbp w; -char *answer; -{ -} - -void getpointername(w, answer) -wbp w; -char *answer; -{ -} - -void getlinestyle(w, answer) -wbp w; -char *answer; -{ -} - - -void getfg(w, answer) -wbp w; -char *answer; -{ -} - -void getbg(w, answer) -wbp w; -char *answer; -{ -} - -/* - * Set the context's foreground color by color cell. - */ -int isetfg(wb,i) -wbp wb; -int i; -{ - RGBColor c; - STDLOCALS (wb); - - if (-i > gNumColors) return Failed; - GetEntryColor (gPal, -i-1, &c); - wc->contextPtr->fgColor = c; - - SetPort (ws->theWindow); - PmForeColor (-i - 1); - -/* */ - GetGWorld (&(ws->origPort), &(ws->origDev)); - SetGWorld (ws->offScreenGWorld, nil); - ws->lockOK = LockPixels (ws->offScreenPMHandle); - PmForeColor (-i - 1); - UnlockPixels (ws->offScreenPMHandle); - SetGWorld (ws->origPort, ws->origDev); - return Succeeded; -/* */ -} - -/* - * Set the context's background color by color cell. - */ -int isetbg(wb,i) -wbp wb; -int i; -{ - RGBColor c; - STDLOCALS (wb); - - if (-i > gNumColors) return Failed; - GetEntryColor (gPal, -i-1, &c); - wc->contextPtr->bgColor = c; - - SetPort (ws->theWindow); - PmBackColor (-i - 1); -} - -int setfg(wb,s) -wbp wb; -char *s; -{ - long r, g, b; - RGBColor c; - STDLOCALS (wb); - - if (parsecolor (NULL, s, &r, &g, &b) == Succeeded) { - RED (c) = r; - GREEN (c) = g; - BLUE (c) = b; - wc->contextPtr->fgColor = c; - - SetPort (ws->theWindow); - RGBForeColor (&c); - - GetGWorld (&(ws->origPort), &(ws->origDev)); - SetGWorld (ws->offScreenGWorld, nil); - ws->lockOK = LockPixels (ws->offScreenPMHandle); - RGBForeColor (&c); - UnlockPixels (ws->offScreenPMHandle); - SetGWorld (ws->origPort, ws->origDev); - - } - else - return Failed; - - return Succeeded; -} - -int setbg(wb,s) -wbp wb; -char *s; -{ - long r, g, b; - RGBColor c; - STDLOCALS (wb); - - if (parsecolor (NULL, s, &r, &g, &b) == Succeeded) { - RED (c) = r; - GREEN (c) = g; - BLUE (c) = b; - wc->contextPtr->bgColor = c; - SetPort (ws->theWindow); - RGBBackColor (&c); - } - else - return Failed; - - return Succeeded; -} - -int nativecolor(w, s, r, g, b) -wbp w; -char *s; -long *r; -long *g; -long *b; -{ - return 0; -} - -int getvisual(w, answer) -wbp w; -char *answer; -{ -} - -/* - * Initialize client for producing pixels from a window - */ -int getpixel_init(wb, x, y, width, height) -wbp wb; -int x, y, width, height; -{ -} - -/* - * Return pixel (x,y) from a window in long value (rv) - */ -int getpixel(wb, x, y, rv, s) -wbp wb; -int x, y; -long *rv; -char *s; -{ - RGBColor c; - STDLOCALS (wb); - - SetPort (ws->theWindow); - GetCPixel (x, y, &c); - *rv = ((c.red << 8) + c.green) << 8 + c.blue; - sprintf (s, "%d,%d,%d", c.red, c.green, c.blue); - return Succeeded; -} - -void getdrawop(w, answer) -wbp w; -char *answer; -{ -} - - -/* - * getimstr(w, x, y, width, height, paltbl, data) -- get image as a string. - * - * Stores the specified subimage in data, one pixel per byte, and sets - * entries in paltbl corresponding to the pixel values that were used. - */ -/* - * The getimstr() code assumes that a maximum of 256 colors can be onscreen - * at one time. If DMAXCOLORS maximum is raised, code must be added for the - * depth>8 case to reduce the local copy of the image to no more than the - * 256-color maximum allowed in a GIF file. This reduction operation is - * nontrivial; look up "color quantization" in computer graphics literature. - */ -#passthru #if (DMAXCOLORS > 256) -#passthru Deliberate Syntax error -#passthru #endif /* DMAXCOLORS */ - -int getimstr(w, x, y, width, height, paltbl, data) -wbp w; -int x, y, width, height; -struct palentry paltbl[DMAXCOLORS]; -unsigned char *data; -{ -} - -int geticonpos(w, s) -wbp w; -char *s; -{ -} - -void getcanvas(wb, s) -wbp wb; -char *s; -{ - STDLOCALS (wb); - - if (ws->theWindow == (WindowPtr) (NULL)) - sprintf (s, "absent"); - else - switch (ws->visible) { - case kVisible: - sprintf (s, "normal"); - break; - case kInvisible: - sprintf (s, "hidden"); - break; - default: - sprintf (s, "unknown"); - } -} - -/* - * Set the canvas type, either during open (pixmap is null, set a flag) - * or change an existing canvas to a different type. - */ -int setcanvas(wb,s) -wbp wb; -char *s; -{ - STDLOCALS(wb); - - if (!strcmp(s, "iconic")) { - return Failed; /* not supported */ - } - else if (!strcmp(s, "normal")) { - ws->visible = kVisible; - if (ws->theWindow != (WindowPtr) (NULL)) { - ShowHide (ws->theWindow, kVisible); - SelectWindow (ws->theWindow); - } - } - else if (!strcmp(s, "maximal")) { - return Failed; /* not supported */ - } - else if (!strcmp(s, "hidden")) { - ws->visible = kInvisible; - if (ws->theWindow != (WindowPtr) (NULL)) { - ShowHide (ws->theWindow, kInvisible); - } - } - else return RunError; - return Succeeded; -} - -/* - * getpos() - update the window state's notion of its current position - */ -int getpos(w) -wbp w; -{ - if (!w->window->theWindow) return Failed; - return Succeeded; -} - -int getdefault(w, prog, opt, answer) -wbp w; -char *prog, *opt, *answer; -{ -} - -void getdisplay(wbp w, char *answer) -{ - strcpy(answer, "local"); -} - -int setdisplay(wbp w, char *s) -{ - return Failed; -} - -int raiseWindow(w) -wbp w; -{ -} - -int lowerWindow(w) -wbp w; -{ -} - -/* - * rebind() - bind w's context to that of w2. - */ -int rebind(w, w2) -wbp w, w2; -{ -} - -int readimage(w, filename, x, y, status) -wbp w; -char *filename; -int x, y, *status; -{ -} - -int setimage(w, val) -wbp w; -char *val; -{ -} - -/* - * Set the context's line style by name. - */ -int setlinestyle(w, s) -wbp w; -char *s; -{ -} - -/* - * Set the context's fill style by name. - */ -int setfillstyle(w, s) -wbp w; -char *s; -{ -} - -int seticonimage(w, dp) -wbp w; -dptr dp; -{ -} - -int seticonicstate(w,s) -wbp w; -char *s; -{ -} - - -/* - * Draw a character-per-pixel image - */ -int strimage(w, x, y, width, height, e, s, len) -wbp w; -int x, y, width, height; -struct palentry *e; -unsigned char *s; -word len; -{ -} - -char *get_mutable_name(wb, mute_index) -wbp wb; -int mute_index; -{ - RGBColor c; - char *tmp = malloc (28); - STDLOCALS (wb); - - if (-mute_index > gNumColors) return NULL; - GetEntryColor (gPal, -mute_index - 1, &c); - sprintf(tmp, "%d", mute_index); - sprintf(tmp + strlen (tmp) + 1, "%d,%d,%d", c.red, c.green, c.blue); - return tmp; -} - -int set_mutable(wb, i, s) -wbp wb; -int i; -char *s; -{ - long r, g, b; - RGBColor c; - STDLOCALS (wb); - - if (parsecolor (NULL, s, &r, &g, &b) != Succeeded ) - return Failed; - c.red = r; - c.green = g; - c.blue =b; - AnimateEntry (ws->theWindow, -i - 1, &c); - ActivatePalette (ws->theWindow); - -/* - ws->lockOK = LockPixels (ws->offScreenPMHandle); - AnimateEntry ((WindowPtr)(ws->offScreenGWorld), -i-1, &c); - ActivatePalette ((WindowPtr)(ws->offScreenGWorld)); - UnlockPixels (ws->offScreenPMHandle); - */ - return Succeeded; -} - -void free_mutable(w, mute_index) -wbp w; -int mute_index; -{ -} - -/* - * Allocate a mutable color - */ -int mutable_color(wb, argv, argc, retval) -wbp wb; -dptr argv; -int argc; -int *retval; -{ - long r, g, b; - tended char *str; - RGBColor c; - { - STDLOCALS(wb); - - - gNumColors++; - if (gNumColors == 1) { - gPal = NewPalette (gNumColors, nil, pmAnimated, kZeroTolerance); - } - else{ - ResizePalette (gPal, gNumColors); - SetEntryUsage (gPal, gNumColors-1, pmAnimated, kZeroTolerance); - } - SetPalette (ws->theWindow, gPal, true); - -/* */ - ws->lockOK = LockPixels (ws->offScreenPMHandle); - SetPalette((WindowPtr)(ws->offScreenGWorld), gPal, true); - UnlockPixels (ws->offScreenPMHandle); -/* */ - - /* set the color */ - - if (argc > 0) { - if (argc != 1) - return RunError; - else - if (argv[0].dword == D_Integer) { - if (IntVal (argv[0]) >= 0) return Failed; /* must be negative */ - } - else { - if (!cnv:C_string(argv[0], str)) { - ReturnErrVal (103, argv[0], RunError); - } - if (parsecolor (NULL, str, &r, &g, &b) != Succeeded) { - gNumColors--; - return Failed; - } - c.red = r; - c.green = g; - c.blue = b; - } - SetEntryColor (gPal, gNumColors-1, &c); - ActivatePalette (ws->theWindow); -/* - ws->lockOK = LockPixels (ws->offScreenPMHandle); - ActivatePalette ((WindowPtr)(ws->offScreenGWorld)); - UnlockPixels (ws->offScreenPMHandle); - */ - } - - *retval = -gNumColors; - return Succeeded; - } -} - -int setleading(wb, i) -wbp wb; -int i; -{ - STDLOCALS(wb); - - if (i<0) return Failed; - wc->font->fInfo.leading = i; - return Succeeded; -} - -/* - * Set the context's line width - */ -int setlinewidth(wb, linewid) -wbp wb; -LONG linewid; -{ - STDLOCALS(wb); - - if (linewid < 0) return Failed; - wc->contextPtr->pnSize.h = linewid; - wc->contextPtr->pnSize.v = linewid; - return Succeeded; -} - -int setwidth(wb, new_width) -wbp wb; -SHORT new_width; -{ - STDLOCALS(wb); - if (new_width < 0) return Failed; - ws->width = new_width; - return Succeeded; -} - -int setheight(wb, new_height) -wbp wb; -short new_height; -{ - STDLOCALS(wb); - if (new_height < 0) return Failed; - ws->height = new_height; - return Succeeded; -} - -int query_pointer(wb, pp) -wbp wb; -XPoint *pp; -{ - Point mousePt; - STDLOCALS (wb); - - SetPort (ws->theWindow); - GetMouse (&mousePt); - pp->x = mousePt.h; - pp->y = mousePt.v; - return Succeeded; -} - -int query_rootpointer(pp) -XPoint *pp; -{ -} - -void toggle_fgbg(w) -wbp w; -{ -} - -int setwindowlabel(wb, s) -wbp wb; -char *s; -{ - wsp ws = wb->window; - if (ws->windowlabel != NULL) free(ws->windowlabel); - ws->windowlabel = salloc(s); - SetWTitle (ws->theWindow, "\pUntitled"); - return Succeeded; -} - -int seticonlabel(w, val) -wbp w; -char *val; -{ -} - -/* - * setdrawop() - set the drawing operation - */ -int setdrawop(w, val) -wbp w; -char *val; -{ -} - -void setclip(wb) -wbp wb; -{ - Rect r; - STDLOCALS(wb); - - SetRect (&r, wc->clipx, wc->clipy, wc->clipx+wc->clipw, wc->clipy+wc->cliph); - SetPort (ws->theWindow); - ClipRect (&r); -} - -void unsetclip(w) -wbp w; -{ -} - -int allowresize(w, on) -wbp w; -int on; -{ - return 0; -} - -int setgamma(w, gamma) -wbp w; -double gamma; -{ - return 0; -} - -/* - * setpointer() - define a mouse pointer shape - */ -int setpointer(w, val) -wbp w; -char *val; -{ -} - -/* - * setcursor() - - */ -int setcursor(w, on) -wbp w; -int on; -{ - if (on==1) - InitCursor (); - else { - InitCursor (); - HideCursor (); - } - return Succeeded; -} - -int seticonpos(w,s) -wbp w; -char *s; -{ -} - - -/* - * Set the window's font by name. - */ -int setfont(wb,s) -wbp wb; -char **s; -{ - short theFontNum; - STDLOCALS(wb); - - GetFNum (CtoPstr (*s), &theFontNum); - wc->contextPtr->txFont = theFontNum; - return Succeeded; -} - -/* - * sync all the servers ??? - */ -void wsync(w) -wbp w; -{ -} - -/* - * put a character out to a window using the current attributes - */ -int wputc(ci,w) -int ci; -wbp w; -{ -} - -int setgeometry(wb, geo) -wbp wb; -char *geo; -{ - int width = 0, height = 0; - int x = 0, y = 0, status; - char *tmps; - STDLOCALS(wb); - - if ((status = parsegeometry(geo, &x, &y, &width, &height)) == 0) - return RunError; - if (status & 1) { - ws->width = width; - ws->height = height; - } - if (status & 2) { - ws->posx = x; - ws->posy = y; - } - /* insert assigns here: - * ws->posx = ((sign > 0) ? tmp : - * DisplayWidth(stddpy,wd->screen) - ws->width - tmp); - * ws->posy = ((sign > 0) ? tmp : - * DisplayHeight(stddpy,wd->screen) - ws->height - tmp); - */ - return Succeeded; -} - -/* - * wclose - close a window. If is a real on-screen window, - * wait for a DestroyNotify event from the server before returning. - */ -int wclose(wb) -wbp wb; -{ - STDLOCALS (wb); - - DisposeWindow (ws->theWindow); - DisposeGWorld (ws->offScreenGWorld); -} - -/* - * flush a window - */ -void wflush(w) -wbp w; -{ -} - -/* - * get a single item from w's pending queue - */ -int wgetq(wb,res) -wbp wb; -dptr res; -{ - wsp ws; - if (!wb || !(ws = wb->window) || !(ws->theWindow)) return -1; - while (1) { - if (!EVQUEEMPTY (ws)) { - EVQUEGET (ws, *res); - return 1; - } - GetEvents (); - } - return -1; -} - -void warpPointer(w, x, y) -wbp w; -int x, y; -{ - /* can't change cursor location, Inside Mac, Imaging: 8-4 */ -} - -int walert(w, volume) -wbp w; -long volume; -{ - long oldVol; - - GetDefaultOutputVolume(&oldVol); - SetDefaultOutputVolume(volume); - SysBeep (30); - SetDefaultOutputVolume(oldVol); -} - -/* - * write some text to both the window and the pixmap - */ -void xdis(w,s,n) -register wbp w; -char *s; -int n; -{ -} - -wsp GetActiveWindow(void) -{ -} - -#else /* Graphics */ -/* static char junk; /* avoid empty module */ -#endif /* Graphics */ diff --git a/src/runtime/rmacrsc.ri b/src/runtime/rmacrsc.ri deleted file mode 100644 index 78f2a3846..000000000 --- a/src/runtime/rmacrsc.ri +++ /dev/null @@ -1,971 +0,0 @@ -/* - * File: rmacrsc.ri - Mac specific resource - */ - -void MacMain (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 - */ -void 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; - } -*/