Annotation of researchv9/jtools/src/cip/buttons.c, revision 1.1

1.1     ! root        1: /*
        !             2:   %Z%  %M%  version %I% %Q%of %H% %T%
        !             3:   Last Delta:  %G% %U% to %P%
        !             4: */
        !             5: 
        !             6: #include "cip.h"
        !             7: 
        !             8: extern void getKbdText ();
        !             9: extern int currentBrush, copyFlag, thingSelected, editDepth;
        !            10: extern Rectangle brushes[];
        !            11: extern int gridState, videoState, buttonState;
        !            12: 
        !            13: struct thing *
        !            14: doMouseButtons(t,offset) 
        !            15: register struct thing *t;
        !            16: Point offset;
        !            17: {
        !            18:   Point m;
        !            19:   register Rectangle *b;
        !            20:   register struct thing *t1;
        !            21:  
        !            22:     if (P->state & RESHAPED) {
        !            23:       /* Redraw screen if layer has been reshaped */
        !            24:       redrawLayer (t, offset);
        !            25:       return(t);
        !            26:     }
        !            27:     if (ptinrect (MOUSE_XY, brushes[PIC])) {
        !            28:       if (P->cursor != &crossHairs) {
        !            29:        cursswitch (&crossHairs);
        !            30:       }
        !            31:     }
        !            32:     else {
        !            33:       if (P->cursor == &crossHairs) {
        !            34:        cursswitch ((Texture *)0);
        !            35:       }
        !            36:     }
        !            37:     m = sub(MOUSE_XY,offset);
        !            38:     if (button1()) {
        !            39:       b = Select(t, add(m,offset), offset);
        !            40:       if ( b == &brushes[PIC]) {
        !            41:        copyFlag=0;
        !            42:        t1 = selectThing(m,t);
        !            43:        if (thingSelected==1) {
        !            44:          drawSelectionLines(t,offset);
        !            45:        }
        !            46:        if (t1 != TNULL) {
        !            47:          t = t1;
        !            48:          thingSelected = 1;
        !            49:          changeBrush(-1);
        !            50:          if (t->type==MACRO||t->type==TEXT) {
        !            51:            changeButtons(MOVEbuttons);
        !            52:          }
        !            53:          else {
        !            54:            changeButtons(EDITbuttons);
        !            55:          }
        !            56:          for(flashThing(t,offset);button1();jnap(2)) ;
        !            57:          drawSelectionLines(t,offset);
        !            58:          flashThing(t,offset);
        !            59:        }
        !            60:        else {
        !            61:          thingSelected = 0;
        !            62:          changeButtons((currentBrush>=0)? DRAWbuttons : INITbuttons);
        !            63:        }
        !            64:       }
        !            65:       else {
        !            66:        if (thingSelected==1) {
        !            67:          drawSelectionLines(t,offset);
        !            68:          thingSelected = 0;
        !            69:        }
        !            70:        if (b != (Rectangle *) NULL ) {
        !            71:          for (; button1(); jnap(2)) ;
        !            72:          copyFlag=0;
        !            73:          thingSelected = 0;
        !            74:          changeButtons(DRAWbuttons);
        !            75:        }
        !            76:       }
        !            77:       for (; button1(); jnap(2)) ;
        !            78:     }
        !            79:     else {
        !            80:       if (button2()) {
        !            81:        if (thingSelected) { 
        !            82:          if (copyFlag!=0) {
        !            83:            drawSelectionLines (t, offset);
        !            84:            t = insert(copyThing(t,m,offset),t);
        !            85:            drawSelectionLines (t, offset);
        !            86:            /* clear button 2 - only one copy per click */
        !            87:            for ( ; button2(); jnap(2)) ;
        !            88:          }
        !            89:          else {
        !            90:            editThing(m,offset,t);
        !            91:          }
        !            92:        }
        !            93:        else {
        !            94:          if ((currentBrush>=0)&&(ptinrect(add(m,offset),brushes[PIC]))) {
        !            95:            if (currentBrush==SPLINE) changeButtons(SPLINEbuttons);
        !            96:            t = place(currentBrush,m,t,offset);
        !            97:            changeButtons(DRAWbuttons);
        !            98:          }
        !            99:          else {
        !           100:            for ( ; button2(); jnap(2)) ;
        !           101:          }
        !           102:        }
        !           103:       }
        !           104:       else {
        !           105:        if (button3()) {
        !           106:          if (thingSelected) {
        !           107:            t = displayThingMenu(m,t,offset);
        !           108:          }
        !           109:          else {
        !           110:            t = displayCommandMenu(t, offset);
        !           111:          }
        !           112:        }
        !           113:       }
        !           114:     }  
        !           115:   return(t);
        !           116: }
        !           117: 
        !           118: struct thing *
        !           119: place(b,p,h,os)
        !           120: register int b;
        !           121: Point p, os;
        !           122: struct thing *h;
        !           123: {
        !           124:   register struct thing *t;
        !           125:   Point r;
        !           126:   register Point *plist, *olist;
        !           127:   register int i, used, room;
        !           128:   struct thing dummy;
        !           129:   register char *s, c;
        !           130: 
        !           131:   r = near(add(p,os),h,os);
        !           132:   if (r.x!=0) {
        !           133:     p = sub(r,os);
        !           134:   }
        !           135:   switch (b) {
        !           136:     case CIRCLE: {
        !           137:       if ((t = newCircle(p)) != TNULL) {
        !           138:        t->otherValues.radius = 1;
        !           139:        draw(t,os);
        !           140:        h = insert(t,h);
        !           141:        track(p,os,GROWCIRCLE,t);
        !           142:        BoundingBox(t);
        !           143:       }
        !           144:       break;   
        !           145:     }
        !           146:     case BOX: {
        !           147:       h = insert(&dummy,h);
        !           148:       r = track(p,os,BOX,h);
        !           149:       if ((t = newBox(canon (p, r))) != TNULL) {
        !           150:        h = remove (&dummy);
        !           151:        h = insert(t,h);
        !           152:       }
        !           153:       else {
        !           154:        draw (h, os);
        !           155:        h = remove (&dummy);
        !           156:       }
        !           157:       break;   
        !           158:     }
        !           159:     case ELLIPSE: {
        !           160:       if ((t = newEllipse(p)) != TNULL) {
        !           161:        t->otherValues.ellipse.ht = 1;
        !           162:        t->otherValues.ellipse.wid = 1;
        !           163:        draw(t,os);
        !           164:        h = insert(t,h);
        !           165:        track(p,os,ELLIPSE,t);
        !           166:        BoundingBox(t);
        !           167:       }
        !           168:       break;   
        !           169:     }
        !           170:     case LINE: {
        !           171:       h = insert(&dummy,h);
        !           172:       r = track(p,os,LINE,h);
        !           173:       if ((t = newLine(p,r)) != TNULL) {
        !           174:        h = remove (&dummy);
        !           175:        h = insert(t,h);
        !           176:       }
        !           177:       else {
        !           178:        draw (h, os);
        !           179:        h = remove (&dummy);
        !           180:       }
        !           181:       break;   
        !           182:     }
        !           183:     case ARC: {
        !           184:       h = insert(&dummy,h);
        !           185:       r = track(p,os,ARC,h);
        !           186:       if ((t = newArc(p,r)) != TNULL) {
        !           187:        h = remove (&dummy);
        !           188:        h = insert(t,h);
        !           189:       }
        !           190:       else {
        !           191:        draw (h, os);
        !           192:        h = remove (&dummy);
        !           193:       }
        !           194:       break;   
        !           195:     }
        !           196:     case SPLINE: {
        !           197:       if ((plist = (Point *)getSpace(5*sizeof(Point)))!=(Point *)NULL) {
        !           198:        h = insert(&dummy,h);
        !           199:        plist[1]=p;
        !           200:        used = 1; room = 3;
        !           201:        do {
        !           202:          if (used==room) {
        !           203:            olist = plist;
        !           204:            room <<= 1;
        !           205:            plist = (Point *) getSpace((room+2)*sizeof(Point));
        !           206:            if (plist==(Point *)NULL) {
        !           207:              draw (&dummy, os);
        !           208:              h = remove (&dummy);
        !           209:              plist = olist;            /* Free list later */
        !           210:              used = 0;
        !           211:              break;
        !           212:            }
        !           213:            for (i=1; i<=used; i++) {
        !           214:              plist[i]=olist[i];
        !           215:            }
        !           216:            free(olist);
        !           217:          }
        !           218:          if (button2()) {
        !           219:            ++used;
        !           220:            plist[used]= track(plist[used-1],os,LINE,h);
        !           221:            xsegment(add(os,plist[used-1]),
        !           222:                      add(os,plist[used]));
        !           223:          }
        !           224:          jnap(2);
        !           225:        } while (!button3());
        !           226:        for (; button3(); jnap(2)) ;
        !           227:        drawZigZag(os,plist,used);
        !           228:        if (used>2) {
        !           229:          t = newSpline(++used,room,plist);
        !           230:        }
        !           231:        else {
        !           232:          t = TNULL;
        !           233:          free (plist);
        !           234:        }
        !           235:        h = remove(&dummy);
        !           236:        h = insert(t,h);
        !           237:       }
        !           238:       break;
        !           239:     }
        !           240:     case TEXT: {
        !           241:       register char s[MAXTEXT+1];
        !           242:       register char *ss;
        !           243:       register char *q, *qq;
        !           244:       getKbdText (s, add(p,os), 0, &carrot, MAXTEXT);
        !           245:       ss = s;
        !           246:       t = TNULL;
        !           247:       if ((q=getSpace(strlen(s)))!=NULL) {
        !           248:        for (qq=q; *qq++ = *ss++;) {
        !           249:        }
        !           250:        t = newText(p,q);
        !           251:        h = insert(t,h);
        !           252:       }
        !           253:       break;
        !           254:     }
        !           255:   }
        !           256:   if (t!=TNULL) {
        !           257:     if (t->type != CIRCLE && t->type != ELLIPSE) {
        !           258:       draw(t,os);
        !           259:     }
        !           260:   }
        !           261:   return(h);
        !           262: }
        !           263: 
        !           264: removeReflectionReferences(m)
        !           265: register struct macro *m;
        !           266: {
        !           267:   register struct macro *t;
        !           268: 
        !           269:   if ((t=m)!=(struct macro *)NULL) {
        !           270:     t->xReflectionOf = (struct macro *) NULL;
        !           271:     t->yReflectionOf = (struct macro *) NULL;
        !           272:     for (t=t->next; t!=(struct macro *)NULL; t=t->next) {
        !           273:       if (t->xReflectionOf==m) {
        !           274:         t->xReflectionOf = (struct macro *) NULL;
        !           275:       }
        !           276:       if (t->yReflectionOf==m) {
        !           277:         t->yReflectionOf = (struct macro *) NULL;
        !           278:       }
        !           279:     } 
        !           280:   }
        !           281: }
        !           282: 
        !           283: clearKeyboard()
        !           284: {
        !           285:   for (; kbdchar() != -1; ) ;
        !           286: }
        !           287: 
        !           288: redrawLayer (h, offset)
        !           289: struct thing *h;
        !           290: Point offset;
        !           291: {
        !           292:   cursinhibit();
        !           293:   brushInit(); /* Init outline of brush boxes. */
        !           294:   drawFrame();         /* display drawing area and brushes */
        !           295:   currentBrush = -1;
        !           296:   buttonState = INITbuttons;
        !           297:   thingSelected = 0;
        !           298:   copyFlag = 0;
        !           299:   doRedraw (h, offset);
        !           300:   if (videoState == BLACKfield) {
        !           301:     rectf(&display, Drect,F_XOR);
        !           302:   }
        !           303:   if (editDepth) {
        !           304:     drawEDbutton (editDepth);
        !           305:   }
        !           306:   cursallow();
        !           307:   P->state &= ~RESHAPED;
        !           308: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.