home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GRIPS 2: Government Rast…rocessing Software & Data
/
GRIPS_2.cdr
/
dos
/
ncsa_tel
/
contribu
/
byu_tel2.hqx
/
vs
/
rsmac.c
next >
Wrap
Text File
|
1990-04-23
|
41KB
|
1,731 lines
#ifndef lint
static char *SCCSid = "%W% (NCSA) %G%";
#endif
/*
*
* Virtual Screen Kernel Macintosh Real Screen Interface
* (rsmac.c)
*
* National Center for Supercomputing Applications
* by Gaige B. Paulsen
*
* This file contains the macintosh real screen calls for the NCSA
* Virtual Screen Kernel.
*
* RSbell(w) - Ring window w's bell
* RScursoff(w) - Turn the cursor off in w
* RScurson(w,x,y) - Turn the cursor on in w at x,y
* RSdraw(w,x,y,a,len,ptr) - Draw @x,y in w string@ptr for length len
* RSdelchars(w,x,y,n) - Delete n chars in w from x,y
* RSdellines(w,t,b,n) - Delete n lines in region t->b in w
* RSerase(w,x1,y1,x2,y2) - Erase from x1,y1 to x2,y2 in w
* RSinitall() - Initialize the world if necessary
* RSinslines(w,t,b,n) - Insert n lines in region t->b in w
* RSinsstring(w,x,y,a,len,ptr)- Insert len chars @x,y in w attrib a
* RSsendstring(w,ptr,len) - Send string @ptr length len from window w
* RSbufinfo( w, total,current)- Tells you the total/current lines in buffer
* RSdrawsep( w, y1,draw) - Tells you to draw the line at y1 (0 is erase)
* RSmargininfo( w, total, current) - Tells you total/current columns in VS
*
*
* Macintosh only Routines:
* NI RSregnconv( *) - Convert region to rect coords
* NI RSsetwind(w) - Set the port and vars to window w
* NI RSsetattr(a) - Set font/text style to a
* NI RSsetConst(w)
* ML RSattatch(w,wind) - Attach the RS (w) to window wind
* ML RSdetatch(w) - Ready window for go-away
* ML RSselect(w,pt,shift) - Handle selection RS (w) point (pt) and (shift) if held down
* ML RSzoom(window,code,shifted) - Zoom Box handling
* ML RSsize( window, where) - Resize handling
* IN RSgetwindow(w) - Get the WindowPtr for RS (w)
* IN RSfindvwind(wind) - Find the (RS/VS) # of wind
* IN RSfindscroll( control, n) - Find which VS the control is in and which control it is
* RSupdate(wind) - Handle updates on WIND, return 0 if not an RS
* RSactivate(w) - Handle activate events
* RSdeactivate(w) - Handle deactivate events
* RSGetTextSel(w,table) - Returns handle to text selection of window w, table->tabs
* RSchangefont(w,fnum,fsiz,r) - Set (w) to font fnum, size fsiz, resize window if (r)
* RSgetfont(w, &fnum, &fsiz) - Get the font size and number into fnum and fsiz
* RSnewwindow( wDims, sb, wid, lines
* name,wrap,fnum,fsiz,
* showit, goaway) - Returns VS # of newly created text window -
* wDims (dimension),sb(scrollback),wid(width 80/132),
* lines (# of lines, 24 <> 66),
* name(window), wrap(0/1),fnum,fsiz, showit(vis),goaway(0,1)
* RSkillwindow( w) - Destroys, deallocates, kills window (w)
* RSclick(window,where,shift,
* option) - Handle clicks in window (returns false if not RS window)
* RShide(w) - Hide RS (w)
* RSshow(w) - Show RS (w)
* RScprompt(w, FilterProc) - Prompt for colors...FilterProc is for Modal Dialog
* RSsetcolor(w,n,r,g,b) - Set one of the 4 colors of RS (w) to R,G,B
* RSgetcolor(w,n,r,g,b) - Get one of the 4 colors of RS (w) into R,G,B
* RSmouseintext(w,myPoint) - Returns true if Mouse is in text part of current RS window
* RSskip(w,on) - Activate/deactivate drawing in an RS
*
* IN - Informational
* ML - Mid Level
* NI - Necessary Internal
* - Suggested calls
*
* Version Date Notes
* ------- ------ ---------------------------------------------------
* 0.01 861102 Initial coding -GBP
* 0.25 861106 Added code from screen.c -GBP
* 0.50 861113 First compiled edition -GBP
* 2.1 871130 NCSA Telnet 2.1 -GBP
* 2.2 880715 NCSA Telnet 2.2 -GBP
*/
#define __ALLNU__
#include <Events.h>
#include <Controls.h>
#include <OSUtils.h>
#include <Dialogs.h>
#include <Quickdraw.h>
#include <Palette.h>
#include <Windows.h>
#include <Menus.h>
#include <Fonts.h>
#include <stdio.h>
#include "vskeys.h"
#include "vsdata.h"
#ifdef MPW
#include "::main:mpw.h"
#include "Picker.h"
#endif
#define NCSA_TELNET
#ifdef NCSA_TELNET
#include "wind.h"
#endif
/*
* Capable of shifting the text to the right some # of pixels
*/
#define CVO 0
#define CHO -3
#define Fheight RSlocal[w].fheight
#define Fascent RSlocal[w].fascent
#define Fwidth RSlocal[w].fwidth
#define FONT RSlocal[w].fnum
#define FSIZE RSlocal[w].fsiz
#define Fright RSlocal[w].width
#define MAXWINDOWWIDTH (width)*Fwidth+16-CHO
#define MAXWINDOWHEIGHT (lines)*Fheight+16
#define putln(x)
extern unsigned char tempspot[];
extern int HasColor; /* BYU mod */
struct RSdata {
Rect textrect; /* Where the text is in the window */
Rect cursor; /* Cursor rectangle */
GrafPtr window; /* Window pointer */
PaletteHandle pal; /* My Palette */
int selected;
long last,
anchor;
int topline,
leftmarg;
int rheight, /* Real window dimensions */
/* adjusted to not include CHO boundary - TK 12/88 */
rwidth;
int height,
width; /* Window Dimensions rounded to the nearest character */
char color[6]; /* color scheme for this machine's sessions */
RGBColor RGBs[4]; /* RGB Colors for window */
ControlHandle
left, /* The CH for the left margin */
scroll; /* The CH for the scroll bar */
int
min, /* Minimum control value */
max, /* Maximum control value */
current, /* current control value */
lmin, /* Minimum control value */
lmax, /* Maximum control value */
lcurrent; /* current control value */
int
fascent, /* Font Ascent */
fnum, /* Font Number */
fsiz, /* Font Size */
fheight, /* Font Height/character */
fwidth, /* Font Width /character */
monospaced; /* Font is monospaced */
int
skip; /* TRUE if we are skipping the output */
};
typedef struct RSdata RSdata;
extern int scrn,numwindows,del;
#ifdef NCSA_TELNET
extern WindRec *screens;
#endif NCSA_TELNET
extern char *VSgetline();
pascal void ScrollProc();
#define MAXRS 20
CTabHandle RSctab;
RSdata *RSlocal;
Rect noConst,
screenRect,
RScur; /* cursor rectangle */
Region **RSuRgn; /* update region */
char **NewHandle();
int RSw=-1, /* last window used */
RSa=0; /* last attrib used */
int RScolor=1; /* true if try to use color stuff */
int RScolors[]=
{ 33, /* black */
30, /* white */
205, /* red */
341, /* green */
409, /* blue */
273, /* cyan */
137, /* magenta */
69 /* yellow */
};
RSinitall()
{
int i;
extern SysEnvRec theWorld;
RSlocal = (RSdata *) malloc(MAXRS*sizeof(RSdata));
for(i=0;i<MAXRS;RSlocal[i++].window=0L) {
RSlocal[i].color[0]=0; /* Foreground */
RSlocal[i].color[1]=1; /* Background */
RSlocal[i].color[2]=2; /* Blink Fore */
RSlocal[i].color[3]=3; /* Blink Back */
RSlocal[i].cursor.top = 0;
RSlocal[i].cursor.bottom = 0;
RSlocal[i].cursor.left = 0;
RSlocal[i].cursor.right = 0;
}
RSuRgn=NewRgn();
RScur.left = 0;
RScur.top = 0;
RScur.bottom = 0;
RScur.right = 0;
RSctab = (CTabHandle)NewHandle( (long)(sizeof(ColorTable)+ 8*sizeof(CSpecArray)) );
RScolor = theWorld.hasColorQD;
}
RSsetConst(w)
int w;
{
SetRect( &noConst, 0,0, RSlocal[w].width, RSlocal[w].height);
}
RSbell(w)
int w;
{
RSsetwind(w);
if (FrontWindow()!=RSlocal[w].window) {
InvertRect(&RSlocal[w].window->portRect);
SysBeep(8);
InvertRect(&RSlocal[w].window->portRect);
}
else SysBeep(8);
}
RScursoff(w)
int w;
{
if (RSlocal[w].skip) return(0);
RSsetwind(w);
InvertRect(&RSlocal[w].cursor);
}
RScurson(w,x,y)
int w,x,y;
{
if (RSlocal[w].skip) return(0);
RSsetwind(w);
RSlocal[w].cursor.left = x * Fwidth;
RSlocal[w].cursor.top = y * Fheight;
RSlocal[w].cursor.right = RSlocal[w].cursor.left + Fwidth;
RSlocal[w].cursor.bottom = RSlocal[w].cursor.top + Fheight;
InvertRect(&RSlocal[w].cursor);
}
RSdraw(w,x,y,a,len,ptr)
int w,x,y,a,len;
char *ptr;
{
Rect rect;
int i,ys;
if (RSlocal[w].skip) return(0);
RSsetwind(w);
RSsetattr(0);
SetRect(&rect, (x)*Fwidth, (y)*Fheight, (x+len)*Fwidth, (y+1)*Fheight );
if (RSa!=a) RSsetattr(a);
#ifdef OLDM
if (!RScolor)
#endif OLDM
EraseRect(&rect);
MoveTo( x*Fwidth, (ys=y*Fheight+Fascent));
if (RSlocal[w].monospaced)
DrawText(ptr,0,len);
else
while (len--) {
DrawChar(*ptr++);
MoveTo( (++x)*Fwidth, ys);
}
if (RSlocal[w].selected)
RSinvText(w, RSlocal[w].anchor, RSlocal[w].last, &rect);
}
RSdelcols(w,n)
int w,n;
{
Rect rect;
if (RSlocal[w].skip) return(0);
RSsetwind(w);
SetRect(&rect, 0, 0, Fright, RSlocal[w].height );
ScrollRect(&rect, -n*Fwidth, 0, RSuRgn);
InvalRgn(RSuRgn);
ValidRect(&rect);
SetRect(&rect, RSlocal[w].width-(n*Fwidth), 0, RSlocal[w].width, RSlocal[w].height );
if (RSlocal[w].selected)
RSinvText(w, RSlocal[w].anchor, RSlocal[w].last, &rect);
}
RSdelchars(w,x,y,n)
int w,x,y,n;
{
Rect rect;
if (RSlocal[w].skip) return(0);
RSsetwind(w);
RSsetattr(0);
SetRect(&rect, (x)*Fwidth, y*Fheight, Fright, (y+1)*Fheight );
if ( (x+n)*Fwidth > Fright)
EraseRect( &rect);
else {
ScrollRect(&rect, -Fwidth*n, 0, RSuRgn);
InvalRgn(RSuRgn);
ValidRect(&rect);
if (RSlocal[w].selected) {
HLock(RSuRgn);
RSinvText(w, RSlocal[w].anchor, RSlocal[w].last, &((*RSuRgn)->rgnBBox));
HUnlock(RSuRgn);
}
}
}
RSdellines(w,t,b,n,scrolled)
int w,t,b,n,scrolled;
{
Rect rect;
if (RSlocal[w].skip) return(0);
RSsetwind(w);
RSsetConst(w);
RSsetattr(0);
if (scrolled) {
if (RSlocal[w].selected && scrolled<0) {
RSinvText(w, RSlocal[w].anchor, RSlocal[w].last, &noConst);
RSlocal[w].selected=0;
}
else {
RSlocal[w].last-=65536; /* Subtract one from each of the */
RSlocal[w].anchor-=65536; /* Selection components */
}
}
rect.left = 0;
rect.right = Fright;
rect.top = (t) * Fheight;
rect.bottom = ((b+1)*Fheight);
OffsetRgn(((WindowPeek)RSlocal[w].window)->updateRgn,0,-Fheight*n);
ScrollRect(&rect, 0, -Fheight*n, RSuRgn);
RSsetattr(VSIw->attrib);
InvalRgn(RSuRgn);
SetRect(&rect,0,(b-n+1)*Fheight-1,Fright,(b+1)*Fheight+1);
ValidRect(&rect);
}
RSerase(w,x1,y1,x2,y2)
int w,x1,y1,x2,y2;
{
Rect rect;
if (RSlocal[w].skip) return(0);
RSsetwind(w);
RSsetattr(0);
SetRect(&rect, x1*Fwidth, y1*Fheight, (x2+1)*Fwidth-1, (y2+1)*Fheight+1);
if (rect.left <= 0) /* little buffer strip on left */
rect.left = CHO;
if (rect.right >= RSlocal[w].width-1)
rect.right = RSlocal[w].rwidth-2; /* clear to edge of window, including edge strip */
if (rect.bottom >= RSlocal[w].height-2)
rect.bottom = RSlocal[w].rheight+1; /* clear to bottom edge also */
EraseRect(&rect);
if (RSlocal[w].selected)
RSinvText(w, RSlocal[w].anchor, RSlocal[w].last, &rect);
}
RSinslines(w,t,b,n,scrolled)
int w,t,b,n,scrolled;
{
Rect rect;
if (RSlocal[w].skip) return(0);
RSsetwind(w);
RSsetConst(w);
RSsetattr(0);
if (RSlocal[w].selected && (scrolled <0)) {
RSinvText(w, RSlocal[w].anchor, RSlocal[w].last, &noConst);
RSlocal[w].selected=0;
}
rect.left = 0;
rect.right = Fright;
rect.top = (t) * Fheight;
rect.bottom = ((b+1)*Fheight);
OffsetRgn(((WindowPeek)RSlocal[w].window)->updateRgn,0,Fheight*n);
ScrollRect(&rect, 0, Fheight*n, RSuRgn);
InvalRgn(RSuRgn);
SetRect(&rect,0,(t)*Fheight-1,Fright,(t+n)*Fheight+1);
ValidRect(&rect);
}
RSinscols(w,n)
int w,n;
{
Rect rect;
if (RSlocal[w].skip) return(0);
RSsetwind(w);
SetRect(&rect, 0, 0, Fright, RSlocal[w].height );
ScrollRect(&rect, n*Fwidth, 0, RSuRgn);
InvalRgn(RSuRgn);
ValidRect(&rect);
SetRect(&rect, 0, 0, (n+1)*Fwidth-1, RSlocal[w].height );
if (RSlocal[w].selected)
RSinvText(w, RSlocal[w].anchor, RSlocal[w].last, &rect);
}
RSinsstring(w,x,y,a,len,ptr)
int w,x,y,a,len;
char *ptr;
{
Rect rect;
if (RSlocal[w].skip) return(0);
RSsetwind(w);
SetRect(&rect, (x)*Fwidth, y*Fheight, Fright, (y+1)*Fheight );
ScrollRect(&rect, len*Fwidth, 0, RSuRgn);
if (RSa!=a) RSsetattr(a);
InvalRgn(RSuRgn);
ValidRect(&rect);
SetRect(&rect, (x)*Fwidth, y*Fheight, (x+len)*Fwidth, (y+1)*Fheight );
EraseRect(&rect);
MoveTo( (x)*Fwidth, y*Fheight+Fascent);
DrawText(ptr,0,len);
if (RSlocal[w].selected)
RSinvText(w, RSlocal[w].anchor, RSlocal[w].last, &rect);
}
RSsendstring(w,ptr,len)
int w, len;
char *ptr;
{
int temp;
#ifdef NCSA_TELNET
temp=findbyVS(w);
if (temp<0) return;
netwrite(screens[temp].port,ptr,len);
#else
while (len--) putu(*ptr++);
#endif
}
RSmargininfo( w, total, current)
int w, total, current;
{
RSlocal[w].leftmarg= current; /* Adjust local vars */
if (RSlocal[w].lcurrent != current)
SetCtlValue( RSlocal[w].left, (RSlocal[w].lcurrent=current) );
if (RSlocal[w].lmax !=total )
SetCtlMax( RSlocal[w].left, (RSlocal[w].lmax= total) );
}
RSbufinfo( w, total, current,bottom)
int w, total, current;
{
RSlocal[w].topline= current; /* Adjust local vars */
if (RSlocal[w].min != -total) {
SetCtlMin( RSlocal[w].scroll, (RSlocal[w].min = -total) );
SetCtlValue( RSlocal[w].scroll, (RSlocal[w].current=current) );
}
if (RSlocal[w].current != current)
SetCtlValue( RSlocal[w].scroll, (RSlocal[w].current=current) );
if (RSlocal[w].max !=( (VSgetlines(w)-1) -(bottom-current))) {
SetCtlMax( RSlocal[w].scroll, (RSlocal[w].max= (VSgetlines(w)-1)- (bottom-current)) );
SetCtlValue( RSlocal[w].scroll, (RSlocal[w].current=current) );
}
}
GrafPtr RSgetwindow(w)
int w;
{
return(RSlocal[w].window);
}
/****************************************************************************/
/* Given a window record number, do a SetPort() to the window associated with
* that window record.
*/
int RSsetwind(w)
int w;
{
if ((w<0) || (w>20)) return(-3);
if (RSw!=w) { /* if last window used is different */
if (RSlocal[w].window==0L) return(-4);
RSw=w;RSa=-1; /* remember this one now, reset attributes */
SetPort(RSlocal[w].window);
return(1);
}
SetPort(RSlocal[w].window);
return(0);
}
RSsetattr(a)
int a;
{
if (VSisgrph(a))
TextFont(74);
else TextFont(RSlocal[RSw].fnum);
TextSize(RSlocal[RSw].fsiz);
TextFace((a & 1) + (a & 0x08) /2);
if (RScolor) {
if (VSisrev(a))
TextMode( notSrcCopy);
else
TextMode( srcCopy);
}
else {
if (VSisrev(a)) {
BackPat(qd.black); /* Reverses current attributes regard */
PenPat(qd.white); /* less of the color, etc.... */
} else {
BackPat(qd.white);
PenPat(qd.black);
}
}
if (VSisblnk(a) ) {
if (RScolor) {
PmForeColor(2);
PmBackColor(3);
} else {
ForeColor( (long) RScolors[ RSlocal[RSw].color[2]]); /* Blink foreground */
BackColor( (long) RScolors[ RSlocal[RSw].color[3]]); /* Blink Background */
}
}
else {
if (RScolor) {
PmForeColor(0);
PmBackColor(1);
} else {
ForeColor( (long) RScolors[ RSlocal[RSw].color[0]]); /* normal foreground */
BackColor( (long) RScolors[ RSlocal[RSw].color[1]]); /* normal Background */
}
}
RSa=a;
}
RSattatch(w,wind)
int w;
GrafPtr wind;
{
RSlocal[w].window=wind;
RSlocal[w].selected=0;
SetPort(wind);
TextFont(FONT);
TextSize(FSIZE);
if (!RScolor)
TextMode(srcXor); /* Xor mode*/
else
TextMode(srcCopy);
RSw=-1; /*make sure we don't write in wrong place */
}
RSdetatch(w)
int w;
{
RSlocal[w].window=0L;
RSw=-1; /*make sure we don't write in wrong place */
}
int RSfindvwind(wind)
GrafPtr wind;
{
int i=0;
while((RSlocal[i].window!=wind) && (i<20)) i++;
if((RSlocal[i].window==0L) || (i>=20)) return(-4);
else return(i);
}
int RSfindscroll( control, n) /* Find screen index by control*/
ControlHandle control;
int *n;
{
*n=0;
while((*n<MAXRS) && (control!=RSlocal[*n].scroll)) (*n)++;
if (*n<MAXRS) return(1);
*n=0;
while((*n<MAXRS) && (control!=RSlocal[*n].left)) (*n)++;
if (*n<MAXRS) return(2);
return(-1);
}
RSregnconv(regn,x1,y1,x2,y2,fh,fw)
Region **regn;
int *x1,*x2,*y1,*y2,fw,fh;
{
HLock(regn);
*y1=((*regn)->rgnBBox.top)/fh;
*y2=(((*regn)->rgnBBox.bottom)+fh-1)/fh;
*x1=((*regn)->rgnBBox.left)/fw;
*x2=(((*regn)->rgnBBox.right)+fw-1)/fw;
HUnlock(regn);
if (*x1<0) *x1=0;
if (*y1<0) *y1=0;
if (*x2<0) *x2=0;
if (*y2<0) *y2=0;
#ifdef WHONEEDSIT
if (*x1>VSIw->maxwidth) *x1=VSIw->maxwidth;
if (*x2>VSIw->maxwidth) *x2=VSIw->maxwidth;
if (*y1>VSIw->lines) *y1=VSIw->lines;
if (*y2>VSIw->lines) *y2=VSIw->lines;
#endif WHONEEDSIT
}
RSupdate(wind)
GrafPtr wind;
{
int w,x1,x2,y1,y2;
int temp;
Rect growRect, rect;
w=RSfindvwind(wind);
if (RSsetwind(w)<0) return(-1);
BeginUpdate(wind);
/* EraseRect( &wind->portRect); */
RSregnconv(wind->visRgn,&x1,&y1,&x2,&y2, Fheight, Fwidth);
VSredraw(w,x1,y1,x2,y2);
/* We must reset, less we risk looking UGLY as sin... */
BackPat(qd.white);
PenPat(qd.black);
if (RScolor) {
PmForeColor(0);
PmBackColor(1);
} else {
ForeColor( (long) RScolors[ RSlocal[w].color[0]]); /* normal foreground */
BackColor( (long) RScolors[ RSlocal[w].color[1]]); /* normal Background */
}
RSa=-1;
PenMode(patOr);
DrawGrowIcon(wind);
PenMode(patCopy);
DrawControls(wind);
/* if ( RSlocal[w].left)
|| RSlocal[w].scroll ) {
}
*/
#ifdef NOHORIZ
SetRect(&growRect,Fright,RSlocal[RSw].height,Fright+15,RSlocal[RSw].height+15);
ClipRect(&growRect);
SetRect(&growRect,0,0,32767,32767);
ClipRect(&growRect);
#endif NOHORIZ
EndUpdate(wind);
return(0);
}
#ifdef FASTERCOMMENTED
RSupdprint(wind)
WindowPeek wind;
{
int x,y,z,w;
char tbuf[50];
RSregnconv(wind->updateRgn,&x,&y,&z,&w);
sprintf(tbuf,"RSregnconv: %d,%d,%d,%d",x,y,z,w);
putln(tbuf);
}
#endif
RSinvText(w, curr,last,constrain)
int w;
Point curr,last;
Rect *constrain;
{
Rect temp,temp2;
char tbuf[100];
Point lb,ub;
RSsetwind(w);
curr.v -=RSlocal[w].topline; /* Adjust the coords */
curr.h -=RSlocal[w].leftmarg;
last.v -=RSlocal[w].topline; /* For both spots.... */
last.h -=RSlocal[w].leftmarg;
if (curr.v==last.v) {
if (curr.h<last.h) {ub= curr;lb=last;} else {ub=last;lb=curr;}
SetRect(&temp,((ub.h+1)*Fwidth),(ub.v*Fheight),
((lb.h+1)*Fwidth), ((lb.v+1) *Fheight));
SectRect(&temp,constrain,&temp2);
HiliteMode();
InvertRect(&temp2);
}
else if (curr.v!=last.v) {
if (curr.v<last.v) ub= curr; else ub=last;
if (curr.v>last.v) lb= curr; else lb=last;
SetRect(&temp,((ub.h+1)*Fwidth),(ub.v*Fheight),
Fright, ((ub.v+1) *Fheight));
SectRect(&temp,constrain,&temp2);
HiliteMode();
InvertRect(&temp2);
SetRect(&temp, 0, (lb.v*Fheight),
((lb.h+1)*Fwidth), ((lb.v+1) *Fheight));
SectRect(&temp,constrain,&temp2);
HiliteMode();
InvertRect(&temp2);
if (lb.v-ub.v>1) {
SetRect(&temp,0,(ub.v+1)*Fheight,Fright,(lb.v*Fheight));
SectRect(&temp,constrain,&temp2);
HiliteMode();
InvertRect(&temp2);
}
}
}
long getlocalmouse(wind)
GrafPtr wind;
{
Point temp;
char tbuf[50];
SetPort(wind);
GetMouse(&temp);
return( * ((long *) &temp));
}
#define Fwidthhalf Fwidth/2
long normalize(in, w)
Point in;
int w;
{
char tbuf[100];
if (in.v<0) {in.v=0; VSscrolback( w,1);}
if (in.v>RSlocal[ w].height) {in.v=RSlocal[ w].height; VSscrolforward( w,1);}
in.v=in.v/Fheight;
if (in.h<0) {in.h=-1; VSscrolleft( w,1);}
if (in.h>RSlocal[ w].width) {in.h=RSlocal[ w].width; VSscrolright( w,1);}
in.h=(in.h+Fwidthhalf)/Fwidth-1;
in.v += RSlocal[ w].topline;
in.h += RSlocal[ w].leftmarg;
return( * ((long *) &in));
}
RSselect( w, pt, shift)
int w;
short shift;
long *pt;
{
GrafPtr tempwndo;
long curr;
char temp[50];
RSsetConst( w);
tempwndo = RSlocal[ w].window;
if (RSlocal[ w].selected) {
if (!shift) {
RSinvText( w, RSlocal[ w].anchor,
RSlocal[ w].last, &noConst);
curr=RSlocal[ w].last=RSlocal[ w].anchor=normalize(*pt, w);
RSlocal[ w].selected=1;
}
}
else {
curr=RSlocal[ w].anchor=RSlocal[ w].last=normalize(*pt, w);
RSlocal[ w].selected=1;
}
while(StillDown()) {
while(((curr=normalize(getlocalmouse(tempwndo), w))==RSlocal[ w].last)
&& StillDown());
RSinvText( w,curr,RSlocal[ w].last, &noConst);
RSlocal[ w].last=curr;
}
if (RSlocal[ w].anchor==curr ||
RSlocal[ w].anchor==RSlocal[ w].last ) RSlocal[ w].selected=0;
if (RSlocal[ w].selected) {
sprintf(temp, "(%d,%d) - (%d,%d) is selected", RSlocal[ w].anchor,RSlocal[ w].last);
putln(temp);
}
}
RSactivate(w)
int w;
{
int temp;
RSsetConst(w);
DrawGrowIcon(RSlocal[w].window);
if (RSlocal[w].scroll !=0L) HiliteControl( RSlocal[w].scroll, 0);
if (RSlocal[w].left !=0L) HiliteControl( RSlocal[w].left , 0);
}
RSdeactivate(w)
int w;
{
int temp;
RSsetConst(w);
DrawGrowIcon(RSlocal[w].window);
if (RSlocal[w].scroll !=0L) HiliteControl( RSlocal[w].scroll, 255);
if (RSlocal[w].left !=0L) HiliteControl( RSlocal[w].left , 255);
}
char **RSGetTextSel(w, table)
int w, table;
{
char **charh, *charp, *t;
int maxwid,i;
long realsiz, VSgettext();
char tempc[100];
Point Anchor,Last;
putln("In the routine");
if (!RSlocal[w].selected) return(0L); /* No Selection */
maxwid= VSmaxwidth( w);
Anchor = *((Point *) &RSlocal[w].anchor);
Last = *((Point *) &RSlocal[w].last);
realsiz= Anchor.v - Last.v;
if (realsiz<0) realsiz = - realsiz;
realsiz ++; /* lines 2,3 selected can be 2 lines */
realsiz *= (maxwid+2);
sprintf(tempc,"Size of block=%d",realsiz);
putln(tempc);
charh=NewHandle( realsiz);
if (charh==0L)
return((char *) -1L); /* Boo Boo return */
HLock(charh);
charp=*charh;
realsiz=VSgettext(w, Anchor.h ,Anchor.v, Last.h ,Last.v , charp, realsiz, "\015", table);
putln("unlocking");
HUnlock(charh);
SetHandleSize(charh,realsiz);
sprintf(tempc,"Size of clip=%d",realsiz);
putln(tempc);
return(charh);
}
RSsetsize( w,v,h)
int w,v,h;
{
Rect eraseit;
int screen;
RSlocal[ w].height=( (v-16+CVO) /Fheight) *Fheight;
RSlocal[ w].width=( (h-16+CHO) /Fwidth) *Fwidth;
RSlocal[ w].rheight=v-16;
RSlocal[ w].rwidth=h-16;
/*
* Get rid of the scroll bars which were in the old size.
* Hiding them causes the region to be updated later.
*/
if (RSlocal[ w].scroll != NULL )
HideControl(RSlocal[ w].scroll);
if (RSlocal[ w].left != NULL )
HideControl(RSlocal[ w].left);
DrawGrowIcon(RSlocal[w].window); /* Draw in the necessary bugger */
if (RSlocal[ w].scroll != NULL ) {
SizeControl(RSlocal[ w].scroll, 16, (v-13));
MoveControl(RSlocal[ w].scroll, (h-15)+CHO, -1+CVO);
ShowControl(RSlocal[ w].scroll);
}
if (RSlocal[ w].left != NULL ) {
SizeControl(RSlocal[ w].left, (h-13), 16);
MoveControl(RSlocal[ w].left, -1+CHO, (v-15)+CVO);
ShowControl(RSlocal[ w].left);
}
SetRect(&RSlocal[w].textrect, 0,0, RSlocal[w].rwidth, RSlocal[w].rheight);
}
RSdrawsep( w, y1,draw)
int w,y1, draw;
{
#ifdef SEPLINE
RSsetwind(w);
PenPat(gray);
if ( draw)
PenMode(srcCopy);
else
PenMode(srcXor);
MoveTo(0,y1*Fheight);
Line( RSlocal[w].width-1, 0);
PenMode(srcOr);
RSsetattr(0);
#endif SEPLINE
}
int RSchangefont( w, fnum, fsiz, resizwind)
int w, fnum, fsiz, resizwind;
{
FontInfo finforec;
Rect pRect;
int t, tw, h,v,x1,x2,y1,y2,width,lines;
int srw,srh;
WStateData *wstate;
WindowPeek wpeek;
RSsetwind(w);
srw=RSlocal[w].rwidth;
srh=RSlocal[w].rheight;
if (fnum) {
TextFont( fnum);
RSlocal[w].fnum=fnum;
}
if (fsiz) {
TextSize( fsiz);
RSlocal[w].fsiz=fsiz;
}
GetFontInfo( &finforec);
RSlocal[w].fwidth=finforec.widMax;
RSlocal[w].fascent=finforec.ascent;
RSlocal[w].fheight=finforec.ascent+finforec.descent+finforec.leading /* +1 */;
RSlocal[w].monospaced= (CharWidth('W')==CharWidth('i'));
RSlocal[w].fwidth= CharWidth('W');
width=VSmaxwidth(w)+1;
lines=VSgetlines(w);
if (!resizwind) {
RSlocal[ w].height=( (RSlocal[ w].rheight) /Fheight) *Fheight;
RSlocal[ w].width =( (RSlocal[ w].rwidth + CHO) /Fwidth ) *Fwidth - CHO;
}
else {
VSgetrgn( w, &x1,&y1,&x2,&y2);
RSlocal[ w].rwidth = RSlocal[ w].width = (x2 - x1 +1) *Fwidth - CHO;
RSlocal[ w].rheight = RSlocal[ w].height= (y2 - y1 +1) *Fheight;
}
if ( RSlocal[ w].rwidth > MAXWINDOWWIDTH-16-CHO)
RSlocal[ w].rwidth = MAXWINDOWWIDTH-16-CHO;
if ( RSlocal[ w].rheight > MAXWINDOWHEIGHT-16)
RSlocal[ w].rheight = MAXWINDOWHEIGHT-16;
if ( (srw !=RSlocal[w].rwidth) || (srh !=RSlocal[w].rheight) ) {
SizeWindow( RSlocal[w].window, RSlocal[ w].rwidth +16,
RSlocal[ w].rheight+16, FALSE); /* TRUE if done right */
/* DrawGrowIcon(RSlocal[w].window); need? */
RSsetsize( w, RSlocal[ w].rheight+16, RSlocal[ w].rwidth+16);
}
wpeek= (WindowPeek)RSlocal[w].window;
HLock( wpeek->dataHandle);
wstate= *wpeek->dataHandle;
movmem( &wstate->stdState, &pRect, 8);
pRect.right=pRect.left+MAXWINDOWWIDTH;
if (pRect.right>screenRect.right)
pRect.right=screenRect.right;
pRect.bottom=pRect.top+MAXWINDOWHEIGHT;
movmem( &pRect, &wstate->stdState, 8);
VSgetrgn( w, &x1,&y1,&x2,&y2);
VSsetrgn( w, x1, y1, (int)(x1+ (RSlocal[ w].rwidth )/Fwidth -1),
(int)(y1+ (RSlocal[ w].rheight)/Fheight-1));
VSgetrgn( w, &x1,&y1,&x2,&y2); /* Get new region */
/* wrong call VSredraw( w,0,0,(x2-x1)*Fwidth,(y2-y1)*Fheight); */
DrawGrowIcon(RSlocal[w].window);
VSredraw( w, 0,0, (x2-x1+1), (y2-y1+1));
ValidRect( &RSlocal[w].window->portRect);
}
RSgetfont( w, pfnum, pfsiz)
int w;
int *pfnum, *pfsiz;
{
/*
* Bug fix. RSsetwind's error conditions are all < 0. There is a success condition == 1.
* TK 12/17/88
*/
if (0 > RSsetwind(w)) return -1;
*pfnum=RSlocal[w].fnum;
*pfsiz=RSlocal[w].fsiz;
return(0);
}
int RSnewwindow( wDims, scrollback, width, lines, name, wrapon, fnum, fsiz, showit, goaway)
Rect *wDims;
int wrapon,
goaway,
showit,
scrollback,
fnum,
fsiz,
lines,
width;
char *name;
{
GrafPort gp;
int w;
Rect pRect;
int t,cur,new,wheight,wwidth;
long VSwhereis();
WStateData *wstate;
WindowPeek wpeek;
FontInfo finforec;
w=VSnewscreen( scrollback,(scrollback!=0), width, 1);
if (w<0) {
putln( "Couldn't open Virtual Screen");
return(-1);
}
RSlocal[w].fnum=fnum;
RSlocal[w].fsiz=fsiz;
OpenPort( &gp);
TextFont( fnum);
TextSize( fsiz);
GetFontInfo( &finforec);
RSlocal[w].fwidth=finforec.widMax;
RSlocal[w].fascent=finforec.ascent;
RSlocal[w].fheight=finforec.ascent+finforec.descent+finforec.leading;
RSlocal[w].monospaced= (CharWidth('W')==CharWidth('i'));
RSlocal[w].fwidth= CharWidth('W');
ClosePort( &gp);
if ( (wDims->right -wDims->left) > MAXWINDOWWIDTH)
wDims->right = wDims->left + MAXWINDOWWIDTH;
if ( (wDims->bottom -wDims->top) > MAXWINDOWHEIGHT)
wDims->bottom = wDims->top + MAXWINDOWHEIGHT;
wwidth = wDims->right - wDims->left;
wheight= wDims->bottom - wDims->top;
if (!RScolor)
RSlocal[w].window=NewWindow(0L, wDims, name, showit?TRUE:FALSE, 8, -1L,
goaway?TRUE:FALSE, (long)w);
else {
RGBColor mrgb;
RSlocal[w].window=NewCWindow(0L, wDims, name, showit?TRUE:FALSE, 8, -1L,
goaway?TRUE:FALSE, (long)w);
/* the screen is not there until we can see it..... */
HLock( RSctab);
(*RSctab)->ctSize = 4;
RSlocal[w].RGBs[0].red =(*RSctab)->ctTable[0].rgb.red = 0;
RSlocal[w].RGBs[0].green=(*RSctab)->ctTable[0].rgb.green = 0;
RSlocal[w].RGBs[0].blue =(*RSctab)->ctTable[0].rgb.blue = 0;
RSlocal[w].RGBs[1].red =(*RSctab)->ctTable[1].rgb.red = 65535;
RSlocal[w].RGBs[1].green=(*RSctab)->ctTable[1].rgb.green = 65535;
RSlocal[w].RGBs[1].blue =(*RSctab)->ctTable[1].rgb.blue = 65535;
RSlocal[w].RGBs[2].red =(*RSctab)->ctTable[2].rgb.red = 0;
RSlocal[w].RGBs[2].green=(*RSctab)->ctTable[2].rgb.green = 61183;
RSlocal[w].RGBs[2].blue =(*RSctab)->ctTable[2].rgb.blue = 11060;
RSlocal[w].RGBs[3].red =(*RSctab)->ctTable[3].rgb.red = 61183;
RSlocal[w].RGBs[3].green=(*RSctab)->ctTable[3].rgb.green = 2079;
RSlocal[w].RGBs[3].blue =(*RSctab)->ctTable[3].rgb.blue = 4938;
HUnlock(RSctab);
RSlocal[w].pal = NewPalette( 4, RSctab, pmCourteous, 0);
SetPalette( RSlocal[w].window, RSlocal[w].pal, TRUE);
}
if (RSlocal[w].window==0L) {
printf("Couldn't open Real Window");
return(-2);
}
SetPort( RSlocal[w].window);
SetOrigin(CHO,CVO); /* Cheap way to correct left margin problem */
wpeek = (WindowPeek)RSlocal[w].window;
HLock( wpeek->dataHandle);
wstate = *wpeek->dataHandle;
movmem( wDims, &wstate->userState, 8);
pRect.top=wDims->top;
pRect.left=wDims->left;
pRect.right=pRect.left+MAXWINDOWWIDTH;
if (pRect.right>screenRect.right)
pRect.right=screenRect.right;
pRect.bottom=pRect.top+MAXWINDOWHEIGHT;
movmem( &pRect, &wstate->stdState, 8);
pRect.top = -1+CVO;
pRect.bottom = wheight- 14 + CVO;
pRect.left = wwidth - 15 + CHO;
pRect.right = wwidth + CHO;
RSlocal[w].scroll=NewControl( RSlocal[w].window, &pRect, "", FALSE,
0,0,0,16,1L);
if (RSlocal[w].scroll==0L) {
printf("Couldn't Make Vertical Scroll Bar");
return(-3);
}
pRect.top = wheight-15+CVO;
pRect.bottom = wheight +CVO;
pRect.left = -1+CHO;
pRect.right = wwidth -14+CHO;
RSlocal[w].left=NewControl( RSlocal[w].window, &pRect, "", FALSE,
0,0,0,16,1L);
if (RSlocal[w].left==0L) {
printf("Couldn't Make Horizontal Scroll Bar");
return(-3);
}
RSlocal[w].skip= 0;
RSlocal[w].max = 0;
RSlocal[w].min = 0;
RSlocal[w].current = 0;
RSlocal[w].lmax =0;
RSlocal[w].lmin =0;
RSlocal[w].lcurrent =0;
RSlocal[w].selected =0;
RSsetsize( w, wheight, wwidth);
VSsetlines(w, lines);
VSsetrgn(w, 0,0,((wwidth -16 + CHO)/Fwidth -1),((wheight-16 + CVO)/Fheight -1) );
TextFont(FONT); /* monaco */
TextSize(FSIZE); /* 9 point*/
if (!RScolor)
TextMode(srcXor); /* Xor mode*/
else
TextMode(srcCopy);
if (wrapon)
VSwrite( w, "\033[?7h",5);
return(w);
}
RSkillwindow(w)
int w;
{
int i;
if (!VSdetatch( w )){ /* Detatch the virtual screen */
KillControls( RSlocal[w].window); /* Get rid of those little slidy things */
DisposeWindow( RSlocal[w].window); /* Get rid of the actual window */
RSdetatch( w); /* Detatch from the table */
}
}
RSzoom( window, code, shifted)
GrafPtr window;
int shifted, /* (myEvent.modifiers & shiftKey) */
code;
{
int w,t;
int h,v,x1,x2,y1,y2;
SetPort( window);
/* EraseRect( &window->portRect); */
ZoomWindow( window, code, shifted );
h=window->portRect.right- window->portRect.left;
v=window->portRect.bottom-window->portRect.top;
w=RSfindvwind( window);
RSsetsize( w,v,h);
VSgetrgn( w, &x1,&y1,&x2,&y2);
VSsetrgn( w, x1, y1, (x1+ (h-16+CHO)/Fwidth -1),
(y1 + (v-16+CVO)/Fheight -1));
VSgetrgn( w, &x1,&y1,&x2,&y2); /* Get new region */
/* VSredraw( w,0,0,(x2-x1)*Fwidth,(y2-y1)*Fheight); wrong call parms*/
/* DrawGrowIcon( window); */
VSredraw( w,0,0,x2-x1+1,y2-y1+1);
ValidRect( &window->portRect);
}
/*
* This routine is called when the user presses the grow icon, or when the size of
* the window needs to be adjusted (where==NULL, modifiers==0).
* It limits the size of the window to a legal range.
*/
RSsize( window, where, modifiers)
GrafPtr window;
long *where;
int modifiers;
{
Rect SizRect;
long size;
int w,width,lines;
int t,tw, h,v,x1,x2,y1,y2,th;
if (( w=RSfindvwind(window)) <0)
return(-1);
if (modifiers & cmdKey ) return(0); /* don't allow command-grow */
SetPort(window);
width=VSmaxwidth(w)+1;
lines=VSgetlines(w);
tw=MAXWINDOWWIDTH;
#ifdef LIMIT_WIDTH
if (tw>screenRect.right) tw=screenRect.right - window->portRect.left - CHO;
#endif LIMIT_WIDTH
if (modifiers & 2048 ) th = screenRect.bottom;
else th =MAXWINDOWHEIGHT+1;
SetRect( &SizRect, 48, 48, tw+1 , th);
if (where) { /* grow icon actions */
size=GrowWindow( window, where, &SizRect);
if (size !=0L) {
SizeWindow( window, size & 0xffff,(size>>16) & 0xffff, FALSE);
h=window->portRect.right- window->portRect.left;
v=window->portRect.bottom-window->portRect.top;
}
else
return; /* user skipped growing */
}
else { /* just resize the window */
h=window->portRect.right- window->portRect.left; /* same width */
v = (Fheight)*VSgetlines(w) + 16; /* new height */
SizeWindow( window, h,v, FALSE); /* change it */
}
RSsetsize( w,v,h);
VSgetrgn( w, &x1,&y1,&x2,&y2);
VSsetrgn( w, x1, y1, (x1+ (h-16+CHO)/Fwidth -1),
(y1 + (v-16)/Fheight-1));
VSgetrgn( w, &x1,&y1,&x2,&y2); /* Get new region */
if (modifiers & 2048) /* option key down means we are resizing the window */
VSsetlines( w, y2 - y1+1); /* Make more lines if user really wants em */
VSredraw( w, 0,0, (x2-x1+1), (y2-y1+1));
ValidRect( &window->portRect);
}
RSclick( window, where, shifted, optioned)
GrafPtr window;
long *where;
int shifted;
int optioned;
{
ControlHandle ctrlh;
int w,screen,part,part2,x1,x2,y1,y2;
if (( w=RSfindvwind(window)) <0)
return(-1);
SetPort(window);
GlobalToLocal( where);
if ( (part=FindControl( where, window, &ctrlh)) !=0)
switch(part) {
case inThumb:
part2=TrackControl(ctrlh, where, 0L);
if (part2 == inThumb) {
part=GetCtlValue(ctrlh);
if (ctrlh==RSlocal[ w].scroll) {
VSgetrgn( w, &x1,&y1,&x2,&y2); /* Get region */
VSsetrgn( w,x1,part,x2,part+ (y2-y1));
}
else { /* ctrlh must be .left */
VSgetrgn( w, &x1,&y1,&x2,&y2); /* Get region */
VSsetrgn( w, part, y1, part+(x2-x1), y2);
}
}
break;
case inUpButton:
case inDownButton:
case inPageUp:
case inPageDown:
part2 = TrackControl( ctrlh, where, ScrollProc);
break;
default:
break;
}
else {
if (optioned) {
Point x;
(*(long *)&x)=normalize( *where, w);
VSpossend( w,x.h,x.v,screens[scrn].echo);
}
else
RSselect( w, where, shifted);
}
}
pascal void ScrollProc( control, part)
short part;
ControlHandle control;
{
int w,kind,x1,y2,x2,y1;
Point Loc;
kind = RSfindscroll( control, & w);
VSgetrgn( w, &x1,&y1,&x2,&y2);
if (kind ==2) {
switch (part) {
case inUpButton: /* Up is left */
VSscrolleft( w,1);
break;
case inDownButton: /* Down is right */
VSscrolright( w,1);
break;
case inPageUp:
VSscrolleft( w,x2-x1);
break;
case inPageDown:
VSscrolright( w,x2-x1);
break;
default:
break;
}
}
else if (kind==1) {
switch (part) {
case inUpButton:
VSscrolback( w,1);
break;
case inDownButton:
VSscrolforward( w,1);
break;
case inPageUp:
VSscrolback( w,y2-y1);
break;
case inPageDown:
VSscrolforward( w,y2-y1);
break;
default:
break;
}
}
}
RShide( w)
int w;
{
if (RSsetwind(w)<0) {
return(-1);
}
HideWindow(RSlocal[w].window);
}
RSshow( w)
int w;
{
if (RSsetwind(w)<0) {
return(-1);
}
ShowWindow(RSlocal[w].window);
}
#ifdef NCSA_TELNET
int RScpromptnum=0, RScfontsize=0;
Str255 RScfontname;
#ifdef PROMPTFONT
pascal void RSdrawsize( wind, item)
GrafPtr wind;
int item;
{
short itemType;
Rect ibox;
char **itemh;
RGBColor rgb;
char temp[50];
GetDItem( wind, item, &itemType, &itemh, &ibox);
EraseRect( &ibox);
MoveTo( ibox.left, ibox.top+12);
sprintf(temp, "%d",RScfontsize);
DrawString( temp);
FrameRect( &ibox);
MoveTo( ibox.right, ibox.top+1);
LineTo( ibox.right, ibox.bottom);
LineTo( ibox.left , ibox.bottom);
}
pascal void RSdrawfont( wind, item)
GrafPtr wind;
int item;
{
int itemType;
Rect ibox;
char **itemh;
RGBColor rgb;
GetDItem( wind, item, &itemType, &itemh, &ibox);
EraseRect( &ibox);
MoveTo( ibox.left, ibox.top+12);
DrawString( &RScfontname);
FrameRect( &ibox);
MoveTo( ibox.right, ibox.top+1);
LineTo( ibox.right, ibox.bottom);
LineTo( ibox.left , ibox.bottom);
}
#endif PROMPTFONT
pascal void RScboxdraw( wind, item)
GrafPtr wind;
short item;
{
short itemType;
Rect ibox;
char **itemh;
GetDItem( wind, item, &itemType, &itemh, &ibox);
InsetRect( &ibox, -2, -2);
FrameRect( &ibox);
}
pascal void RScdraw( wind, item)
GrafPtr wind;
short item;
{
short itemType;
Rect ibox;
char **itemh;
RGBColor rgb;
GetDItem( wind, item, &itemType, &itemh, &ibox);
GetForeColor( &rgb);
RGBForeColor( &RSlocal[RScpromptnum].RGBs[item-3]);
PaintRect( &ibox);
RGBForeColor( &rgb);
}
RScprompt( w, FilterProc)
int *FilterProc;
{
short itemType;
short item,x, size,num;
long sresult=1, fresult=1, result;
char sizetemp[10];
static char *cprompt="\pChoose a color:";
Rect ibox,sizebox,fontbox,fnambox,snambox;
char **itemh;
RGBColor rgb,rgb2;
DialogPtr dlog;
Point pt;
MenuHandle fontMH, sizeMH;
GrafPtr OldPort;
pt.h=0;
pt.v=0;
RScpromptnum=w;
#ifdef PROMPTFONT
RScfontsize=RSlocal[w].fsiz;
GetFontName( RSlocal[w].fnum, &RScfontname);
#endif PROMPTFONT
dlog=GetNewDialog( 1001, (Ptr) 0L,(Ptr) -1L);
SetPort( dlog);
#ifdef PROMPTFONT
fontMH=NewMenu( 63, "\PFontPopUp");
AddResMenu( fontMH, 'FONT');
sizeMH=NewMenu( 64, "\PSizePopUp");
AppendMenu(sizeMH, "\P7;9;10;12;18;24;36");
InsertMenu( fontMH, -1);
InsertMenu( sizeMH, -1);
#endif PROMPTFONT
GetDItem( dlog, 3, &itemType, &itemh, &ibox);
SetDItem( dlog, 3, itemType, RScdraw, &ibox);
GetDItem( dlog, 4, &itemType, &itemh, &ibox);
SetDItem( dlog, 4, itemType, RScdraw, &ibox);
GetDItem( dlog, 5, &itemType, &itemh, &ibox);
SetDItem( dlog, 5, itemType, RScdraw, &ibox);
GetDItem( dlog, 6, &itemType, &itemh, &ibox);
SetDItem( dlog, 6, itemType, RScdraw, &ibox);
GetDItem( dlog, 11, &itemType, &itemh, &ibox);
SetDItem( dlog, 11, itemType, RScboxdraw, &ibox);
GetDItem( dlog, 12, &itemType, &itemh, &ibox);
SetDItem( dlog, 12, itemType, RScboxdraw, &ibox);
GetDItem( dlog, 13, &itemType, &itemh, &ibox);
SetDItem( dlog, 13, itemType, RScboxdraw, &ibox);
GetDItem( dlog, 14, &itemType, &itemh, &ibox);
SetDItem( dlog, 14, itemType, RScboxdraw, &ibox);
#ifdef PROMPTFONT
GetDItem( dlog, 11, &itemType, &itemh, &fnambox);
GetDItem( dlog, 12, &itemType, &itemh, &fontbox);
SetDItem( dlog, 12, itemType, RSdrawfont, &fontbox);
LocalToGlobal(&fontbox);
GetDItem( dlog, 13, &itemType, &itemh, &snambox);
GetDItem( dlog, 14, &itemType, &itemh, &sizebox);
SetDItem( dlog, 14, itemType, RSdrawsize, &sizebox);
LocalToGlobal(&sizebox);
#endif PROMPTFONT
item =0;
while (item !=1 && item !=2) {
ModalDialog( FilterProc, &item);
switch (item) {
case 3:
x=GetColor( pt, cprompt, &RSlocal[w].RGBs[0], &rgb2);
if (x)
RSlocal[w].RGBs[0]=rgb2;
break;
case 4:
x=GetColor( pt, cprompt, &RSlocal[w].RGBs[1], &rgb2);
if (x)
RSlocal[w].RGBs[1]=rgb2;
break;
case 5:
x=GetColor( pt, cprompt, &RSlocal[w].RGBs[2], &rgb2);
if (x)
RSlocal[w].RGBs[2]=rgb2;
break;
case 6:
x=GetColor( pt, cprompt, &RSlocal[w].RGBs[3], &rgb2);
if (x)
RSlocal[w].RGBs[3]=rgb2;
break;
#ifdef PROMPTFONT
case 12:
InvertRect( &fnambox);
result = PopUpMenuSelect(fontMH, fontbox.top, fontbox.left, (short) fresult);
result = result & 0xffff;
InvertRect( &fnambox);
if (result >0) {
GetItem( fontMH, (short)result, &RScfontname);
RSdrawfont( dlog, 12);
fresult = result;
}
break;
case 14:
InvertRect( &snambox);
result = PopUpMenuSelect(sizeMH, sizebox.top, sizebox.left, (short) sresult);
result = result & 0xffff;
InvertRect( &snambox);
if (result >0) {
GetItem( sizeMH, (short)result, &sizetemp);
sscanf( sizetemp, "%d", &RScfontsize);
RSdrawsize( dlog, 14);
sresult = result;
}
break;
#endif PROMPTFONT
}
}
DisposDialog(dlog);
SetPort(RSlocal[w].window);
InvalRect(&RSlocal[w].window->portRect);
if ( item ==2)
return(-1);
else
for (x=0;x<4;x++)
SetEntryColor( RSlocal[w].pal, x, &RSlocal[w].RGBs[x]);
/* do something if it changes */;
#ifdef PROMPTFONT
GetFNum( &RScfontname ,&num);
size= RScfontsize;
DeleteMenu( fontMH);
DeleteMenu( sizeMH);
RSchangefont( w, num, size, 1);
#endif PROMPTFONT
return(0);
}
RSsetcolor( w, n, r,g,b)
int w,n;
unsigned int r, g, b;
{
if ( !HasColor || (RSsetwind(w) < 0)) { /* BYU mod */
return(-1);
}
RSlocal[w].RGBs[n].red = r;
RSlocal[w].RGBs[n].green = g;
RSlocal[w].RGBs[n].blue = b;
SetEntryColor( RSlocal[w].pal, n, &RSlocal[w].RGBs[n]);
SetPort(RSlocal[w].window);
InvalRect(&RSlocal[w].window->portRect);
return(0);
}
RSgetcolor( w, n, r,g,b)
int w,n;
unsigned int *r, *g, *b;
{
*r = RSlocal[w].RGBs[n].red;
*g = RSlocal[w].RGBs[n].green;
*b = RSlocal[w].RGBs[n].blue;
}
HiliteMode()
{
char *p = (char *) 0x938;
*p=*p &0x7f;
}
RSmouseintext( w, myPoint) /* Point is in global coords */
long myPoint;
{
return ( PtInRect( &myPoint, &RSlocal[w].textrect ));
}
RSskip(w, on)
int w,on;
{
RSlocal[w].skip=on;
}
/**********************************************************************************/
/* Make sure at least this much memory is available before allocating more memory
* for me. Returns true or false whether that much is available.
*/
RSokmem(amount)
int amount;
{
char *p,*malloc();
if (NULL == (p = malloc(amount)))
return(0);
free(p);
return(1);
}