Reset() { Point shift; Disp *Scan; /* shift is the distance between the location and the new */ shift = sub(Drect.origin,DrectOrigin); /* the new location is now current */ DrectOrigin = Drect.origin; Resize(); /* * There is apparently a linked list of objects to be displayed. * The following loop goes through the list and changes each * objects understanding of where it exits, and marks it to be * redrawn. */ Scan = Pool; while (Scan != DNULL) { if (Scan->Class == FontClass) Scan->Disp.TopFont->r = raddp(Scan->Disp.TopFont->r,shift); else Scan->Disp.TopEdit->r = raddp(Scan->Disp.TopEdit->r,shift); Scan->Redraw = true; Scan = Scan->Next; } /* * redraw traverses the list, and redraws the objects that * need to be redrawn. */ Redraw(); }
/*********************************************************************** This routine is called when the menu command ROTATEMINUS is selected. The region selected is rotated 90 degress counterclockwise. ***********************************************************************/ OpRotMinus() { int vsize, hsize, size; Rectangle r, rbuf; Bitmap * buffer; if (GetIconRect(&r) == 0) return(0); hsize = horsize(r); vsize = versize(r); size = hsize + vsize; buffer = balloc(Rect(0, 0, size, size)); if (buffer == ((Bitmap * ) 0)) return(0); rectf(buffer, buffer->rect, F_CLR); rbuf = raddp(r, sub(Pt(vsize, 0), r.origin)); bitblt(&display, raddp(r, icon.origin), buffer, rbuf.origin, F_XOR); horshear(buffer, rbuf, -vsize, true); vershear(buffer, Rect(rbuf.origin.x - vsize, rbuf.origin.y, rbuf.corner.x, rbuf.corner.y), size, true); horshear(buffer, Rect(rbuf.origin.x - vsize, rbuf.corner.y - 1, rbuf.corner.x, rbuf.corner.y + hsize - 1), hsize, false); Erase(r); FetchIcon(buffer, Rect(rbuf.corner.x - vsize, rbuf.corner.y - 1, rbuf.corner.x, rbuf.corner.y + hsize - 1), add(r.origin, sub(Pt(hsize / 2, vsize / 2), Pt(vsize / 2, hsize / 2))), Rect(0, 0, Xblocks, Yblocks)); bfree(buffer); }
int menuhit(int but, Mouse *m, Menu *menu) { int i, nitem, nitemdrawn, maxwid, lasti, off, noff, wid, screenitem; bool scrolling; Rectangle r, menur, sc, textr, scrollr; Bitmap *b; Point pt; char *item; extern unsigned int cursor; unsigned int oldcursor = cursor; cursorswitch(ArrowCursor); sc = screen.clipr; clipr(&screen, screen.r); maxwid = 0; for(nitem = 0; (item = menu->item? menu->item[nitem] : (*menu->gen)(nitem)); nitem++){ i = strwidth(font, item); if(i > maxwid) maxwid = i; } if(menu->lasthit<0 || menu->lasthit>=nitem) menu->lasthit = 0; screenitem = (Dy(screen.r)-10)/(fontheight()+Vspacing); if(nitem>Maxunscroll || nitem>screenitem){ scrolling = true; nitemdrawn = Nscroll; if(nitemdrawn > screenitem) nitemdrawn = screenitem; wid = maxwid + Gap + Scrollwid; off = menu->lasthit - nitemdrawn/2; if(off < 0) off = 0; if(off > nitem-nitemdrawn) off = nitem-nitemdrawn; lasti = menu->lasthit-off; }else{ scrolling = false; nitemdrawn = nitem; wid = maxwid; off = 0; lasti = menu->lasthit; } r = inset(Rect(0, 0, wid, nitemdrawn*(fontheight()+Vspacing)), -Margin); r = rsubp(r, Pt(wid/2, lasti*(fontheight()+Vspacing)+fontheight()/2)); r = raddp(r, m->xy); pt = Pt(0, 0); if(r.max.x>screen.r.max.x) pt.x = screen.r.max.x-r.max.x; if(r.max.y>screen.r.max.y) pt.y = screen.r.max.y-r.max.y; if(r.min.x<screen.r.min.x) pt.x = screen.r.min.x-r.min.x; if(r.min.y<screen.r.min.y) pt.y = screen.r.min.y-r.min.y; menur = raddp(r, pt); textr.max.x = menur.max.x-Margin; textr.min.x = textr.max.x-maxwid; textr.min.y = menur.min.y+Margin; textr.max.y = textr.min.y + nitemdrawn*(fontheight()+Vspacing); if(scrolling){ scrollr = inset(menur, Border); scrollr.max.x = scrollr.min.x+Scrollwid; }else scrollr = Rect(0, 0, 0, 0); b = balloc(menur, screen.ldepth); if(b == 0) b = &screen; bitblt(b, menur.min, &screen, menur, S); bitblt(&screen, menur.min, &screen, menur, 0); border(&screen, menur, Blackborder, F, _bgpixel); r = menurect(textr, lasti); cursorset(divpt(add(r.min, r.max), 2)); menupaint(menu, textr, off, nitemdrawn); if(scrolling) menuscrollpaint(scrollr, off, nitem, nitemdrawn); r = menurect(textr, lasti); cursorset(divpt(add(r.min, r.max), 2)); menupaint(menu, textr, off, nitemdrawn); if(scrolling) menuscrollpaint(scrollr, off, nitem, nitemdrawn); while(m->buttons & (1<<(but-1))){ lasti = menuscan(but, m, textr, lasti); if(lasti >= 0) break; while(!ptinrect(m->xy, textr) && (m->buttons & (1<<(but-1)))){ if(scrolling && ptinrect(m->xy, scrollr)){ noff = ((m->xy.y-scrollr.min.y)*nitem)/Dy(scrollr); noff -= nitemdrawn/2; if(noff < 0) noff = 0; if(noff > nitem-nitemdrawn) noff = nitem-nitemdrawn; if(noff != off){ off = noff; menupaint(menu, textr, off, nitemdrawn); menuscrollpaint(scrollr, off, nitem, nitemdrawn); } } *m = emouse(); } } bitblt(&screen, menur.min, b, menur, S); if(b != &screen) bfree(b); clipr(&screen, sc); if(lasti >= 0){ menu->lasthit = lasti+off; return cursorswitch(oldcursor), menu->lasthit; } cursorswitch(oldcursor); return -1; }