本文整理匯總了C++中Dy函數的典型用法代碼示例。如果您正苦於以下問題:C++ Dy函數的具體用法?C++ Dy怎麽用?C++ Dy使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Dy函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: colresize
void
colresize(Column *c, Rectangle r)
{
int i;
Rectangle r1, r2;
Window *w;
clearmouse();
textresize(&c->tag, r, TRUE);
draw(screen, c->tag.scrollr, tagcols[TEXT], nil, ZP);
c->r = r;
r1 = r;
for(i=0; i<c->nw; i++){
w = c->w[i];
w->maxlines = 0;
if(i == c->nw-1)
r1.max.y = r.max.y;
else
r1.max.y = r1.min.y+(Dy(w->r)+Border)*Dy(r)/Dy(c->r);
r1.max.y = max(r1.max.y, r1.min.y + Border+font->height);
r2 = r1;
r2.max.y = r2.min.y+Border;
draw(screen, r2, display->black, nil, ZP);
r1.min.y = r2.max.y;
r1.min.y = winresize(w, r1, FALSE, i==c->nw-1);
}
}
示例2: textresize
int
textresize(Text *t, Rectangle r, int keepextra)
{
int odx;
if(Dy(r) <= 0)
r.max.y = r.min.y;
else if(!keepextra)
r.max.y -= Dy(r)%t->fr.font->height;
odx = Dx(t->all);
t->all = r;
t->scrollr = r;
t->scrollr.max.x = r.min.x+Scrollwid;
t->lastsr = nullrect;
r.min.x += Scrollwid+Scrollgap;
frclear(&t->fr, 0);
textredraw(t, r, t->fr.font, t->fr.b, odx);
if(keepextra && t->fr.r.max.y < t->all.max.y && !t->fr.noredraw){
/* draw background in bottom fringe of window */
r.min.x -= Scrollgap;
r.min.y = t->fr.r.max.y;
r.max.y = t->all.max.y;
draw(screen, r, t->fr.cols[BACK], nil, ZP);
}
return t->all.max.y;
}
示例3: grabmouse
void
grabmouse(void*)
{
int fd, x, y;
char ibuf[256], obuf[256];
if(debug)
return;
fd = open("/dev/mouse", ORDWR);
if(fd < 0)
error("can't open /dev/mouse: %r");
snprint(obuf, sizeof obuf, "m %d %d",
screen->r.min.x + Dx(screen->r)/2,
screen->r.min.y + Dy(screen->r)/2);
while(read(fd, ibuf, sizeof ibuf) > 0){
ibuf[12] = 0;
ibuf[24] = 0;
x = atoi(ibuf+1);
y = atoi(ibuf+13);
if(x != screen->r.min.x + Dx(screen->r)/2 ||
y != screen->r.min.y + Dy(screen->r)/2){
fprint(fd, "%s", obuf);
doblank = 1;
}
}
}
示例4: colresize
void
colresize(Column *c, Rectangle r)
{
int i;
Rectangle r1, r2;
Window *w;
clearmouse();
r1 = r;
r1.max.y = r1.min.y + c->tag.font->height;
textresize(&c->tag, r1);
draw(screen, c->tag.scrollr, colbutton, nil, colbutton->r.min);
r1.min.y = r1.max.y;
r1.max.y += Border;
draw(screen, r1, display->black, nil, ZP);
r1.max.y = r.max.y;
for(i=0; i<c->nw; i++){
w = c->w[i];
w->maxlines = 0;
if(i == c->nw-1)
r1.max.y = r.max.y;
else
r1.max.y = r1.min.y+(Dy(w->r)+Border)*Dy(r)/Dy(c->r);
r2 = r1;
r2.max.y = r2.min.y+Border;
draw(screen, r2, display->black, nil, ZP);
r1.min.y = r2.max.y;
r1.min.y = winresize(w, r1, FALSE);
}
c->r = r;
}
示例5: pix2board
Point
pix2board(int x, int y)
{
float d, rx, ry, yh;
int ny, nx;
/* XXX: float→int causes small rounding errors */
d = (float)(Dx(screen->r) > Dy(screen->r)) ? Dy(screen->r) -20: Dx(screen->r)-20;
rx = d/(float)SzX;
rx = rx/2.0;
ry =d/(float)SzY;
ry = ry/2.0;
yh = ry/3.73205082;
/* reverse board2pix() */
ny = (int)(((float)y - ry)/(2*ry - ((y>2*ry)?yh:0.0)) + 0.5); /* ny = (y - ry)/(2ry-yh) */
nx = (int)(((float)x - rx - (ny%2?rx:0.0))/(rx*2.0) + 0.5); /* nx = (x - rx - rx)/2rx */
if (nx >= SzX)
nx = SzX-1;
if (ny >=SzY)
ny = SzY-1;
return Pt(nx, ny);
}
示例6: showpage
void
showpage(int page, Menu *m)
{
if(doc->fwdonly)
m->lasthit = 0; /* this page */
else
m->lasthit = reverse ? doc->npage-1-page : page;
esetcursor(&reading);
delayfreeimage(nil);
im = cachedpage(doc, angle, page);
if(im == nil)
wexits(0);
if(resizing)
resize(Dx(im->r), Dy(im->r));
esetcursor(nil);
if(showbottom){
ul.y = screen->r.max.y - Dy(im->r);
showbottom = 0;
}
redraw(screen);
flushimage(display, 1);
}
示例7: resize
void
resize(void)
{
Rectangle old, r;
int dxo, dyo, dxn, dyn;
Win *w;
old = screen->r;
dxo = Dx(old);
dyo = Dy(old);
if(getwindow(display, Refnone) < 0)
sysfatal("resize failed: %r");
dxn = Dx(screen->r);
dyn = Dy(screen->r);
freescreen(scr);
scr = allocscreen(screen, display->white, 0);
if(scr == nil)
sysfatal("allocscreen: %r");
for(w = wlist.next; w != &wlist; w = w->next){
r = rectsubpt(w->entire, old.min);
r.min.x = muldiv(r.min.x, dxn, dxo);
r.max.x = muldiv(r.max.x, dxn, dxo);
r.min.y = muldiv(r.min.y, dyn, dyo);
r.max.y = muldiv(r.max.y, dyn, dyo);
w->entire = rectaddpt(r, screen->r.min);
w->inner = insetrect(w->entire, BORDSIZ);
freeimage(w->im);
w->im = allocwindow(scr, w->entire, Refbackup, 0);
if(w->im == nil)
sysfatal("allocwindow: %r");
draw(w->im, w->inner, w->tab->cols[BACK], nil, ZP);
border(w->im, w->entire, BORDSIZ, w->tab->cols[w == actw ? BORD : DISB], ZP);
w->tab->draw(w);
}
}
示例8: stack_info
void
stack_info(Frame *f, Frame **firstp, Frame **lastp, int *dyp, int *nframep) {
Frame *ft, *first, *last;
int dy, nframe;
nframe = 0;
dy = 0;
first = f;
last = f;
for(ft=f; ft && ft->collapsed; ft=ft->anext)
;
if(ft && ft != f) {
f = ft;
dy += Dy(f->colr);
}
for(ft=f; ft && !ft->collapsed; ft=ft->aprev) {
first = ft;
nframe++;
dy += Dy(ft->colr);
}
for(ft=f->anext; ft && !ft->collapsed; ft=ft->anext) {
if(first == nil)
first = ft;
last = ft;
nframe++;
dy += Dy(ft->colr);
}
if(nframep) *nframep = nframe;
if(firstp) *firstp = first;
if(lastp) *lastp = last;
if(dyp) *dyp = dy;
}
示例9: tkcvsrectdraw
void
tkcvsrectdraw(Image *img, TkCitem *i, TkEnv *pe)
{
int lw, rw;
TkEnv *e;
TkCrect *r;
Rectangle d, rr;
Point tr, bl;
Image *pen;
USED(pe);
d.min = i->p.drawpt[0];
d.max = i->p.drawpt[1];
e = i->env;
r = TKobj(TkCrect, i);
pen = nil;
if((e->set & (1<<TkCfill)))
pen = tkgc(e, TkCfill);
if(pen != nil)
draw(img, d, pen, r->stipple, d.min);
tr.x = d.max.x;
tr.y = d.min.y;
bl.x = d.min.x;
bl.y = d.max.y;
rw = (TKF2I(r->width) + 1)/2;
if(rw <= 0)
return;
lw = (TKF2I(r->width))/2;
pen = tkgc(e, TkCforegnd);
if(pen != nil) {
/* horizontal lines first */
rr.min.x = d.min.x - lw;
rr.max.x = d.max.x + rw;
rr.min.y = d.min.y - lw;
rr.max.y = d.min.y + rw;
draw(img, rr, pen, nil, rr.min);
rr.min.y += Dy(d);
rr.max.y += Dy(d);
draw(img, rr, pen, nil, rr.min);
/* now the vertical */
/* horizontal lines first */
rr.min.x = d.min.x - lw;
rr.max.x = d.min.x + rw;
rr.min.y = d.min.y + rw;
rr.max.y = d.max.y - lw;
draw(img, rr, pen, nil, rr.min);
rr.min.x += Dx(d);
rr.max.x += Dx(d);
draw(img, rr, pen, nil, rr.min);
}
}
示例10: gendrawdiff
/*
* A draw operation that touches only the area contained in bot but not in top.
* mp and sp get aligned with bot.min.
*/
static void
gendrawdiff(Image *dst, Rectangle bot, Rectangle top,
Image *src, Point sp, Image *mask, Point mp, int op)
{
Rectangle r;
Point origin;
Point delta;
USED(op);
if(Dx(bot)*Dy(bot) == 0)
return;
/* no points in bot - top */
if(rectinrect(bot, top))
return;
/* bot - top ≡ bot */
if(Dx(top)*Dy(top)==0 || rectXrect(bot, top)==0){
gendrawop(dst, bot, src, sp, mask, mp, op);
return;
}
origin = bot.min;
/* split bot into rectangles that don't intersect top */
/* left side */
if(bot.min.x < top.min.x){
r = Rect(bot.min.x, bot.min.y, top.min.x, bot.max.y);
delta = subpt(r.min, origin);
gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op);
bot.min.x = top.min.x;
}
/* right side */
if(bot.max.x > top.max.x){
r = Rect(top.max.x, bot.min.y, bot.max.x, bot.max.y);
delta = subpt(r.min, origin);
gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op);
bot.max.x = top.max.x;
}
/* top */
if(bot.min.y < top.min.y){
r = Rect(bot.min.x, bot.min.y, bot.max.x, top.min.y);
delta = subpt(r.min, origin);
gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op);
bot.min.y = top.min.y;
}
/* bottom */
if(bot.max.y > top.max.y){
r = Rect(bot.min.x, top.max.y, bot.max.x, bot.max.y);
delta = subpt(r.min, origin);
gendrawop(dst, r, src, addpt(sp, delta), mask, addpt(mp, delta), op);
bot.max.y = top.max.y;
}
}
示例11: redraw
void
redraw(Image *screen)
{
Rectangle r = Rect(0,0,Dx(screen->r), Dy(screen->r));
catoffs.x=(Dx(r)-CATWID)/2;
catoffs.y=(Dy(r)-CATHGT)/2;
if(!ptinrect(catoffs, r)) fprint(2, "catclock: window too small, resize!\n");
xredraw=1;
}
示例12: mga4xxscroll
static int
mga4xxscroll(VGAscr *scr, Rectangle dr, Rectangle sr)
{
uchar * mga;
int pitch;
int width, height;
ulong start, end, sgn;
Point sp, dp;
if(scr->mmio == 0)
return 0;
mga = (uchar*)scr->mmio;
assert(Dx(sr) == Dx(dr) && Dy(sr) == Dy(dr));
sp = sr.min;
dp = dr.min;
if(eqpt(sp, dp))
return 1;
pitch = Dx(scr->gscreen->r);
width = Dx(sr);
height = Dy(sr);
sgn = 0;
if(dp.y > sp.y && dp.y < sp.y + height){
sp.y += height - 1;
dp.y += height - 1;
sgn |= SGN_UP;
}
width--;
start = end = sp.x + (sp.y * pitch);
if(dp.x > sp.x && dp.x < sp.x + width){
start += width;
sgn |= SGN_LEFT;
}
else
end += width;
mga_fifo(mga, 8);
mgawrite32(mga, DWGCTL, 0);
mgawrite32(mga, SGN, sgn);
mgawrite32(mga, AR5, sgn & SGN_UP ? -pitch : pitch);
mgawrite32(mga, AR0, end);
mgawrite32(mga, AR3, start);
mgawrite32(mga, FXBNDRY, ((dp.x + width) << 16) | dp.x);
mgawrite32(mga, YDSTLEN, (dp.y << 16) | height);
mgawrite32(mga, DWGCTL + GO, DWG_BITBLT | DWG_SHIFTZERO | DWG_BFCOL | DWG_REPLACE);
while(mgaread32(mga, STATUS) & 0x00010000)
;
return 1;
}
示例13: column_surplus
static int
column_surplus(Area *a) {
Frame *f;
int surplus;
surplus = Dy(a->r);
for(f=a->frame; f; f=f->anext)
surplus -= Dy(f->r);
return surplus;
}
示例14: unloadimage
int
unloadimage(Image *i, Rectangle r, uchar *data, int ndata)
{
int bpl, n, chunk, dx, dy;
uchar *a, *start;
Display *d;
if(!rectinrect(r, i->r)) {
werrstr("unloadimage: bad rectangle");
return -1;
}
bpl = bytesperline(r, i->depth);
if(ndata < bpl*Dy(r)) {
werrstr("unloadimage: buffer too small");
return -1;
}
start = data;
d = i->display;
chunk = d->bufsize;
flushimage(d, 0); /* make sure subsequent flush is for us only */
while(r.min.y < r.max.y) {
dx = Dx(r);
dy = chunk/bpl;
if(dy <= 0) {
dy = 1;
dx = ((chunk*dx)/bpl) & ~7;
n = bytesperline(Rect(r.min.x, r.min.y, r.min.x+dx, r.min.y+dy), i->depth);
if(unloadimage(i, Rect(r.min.x+dx, r.min.y, r.max.x, r.min.y+dy), data+n, bpl-n) < 0)
return -1;
} else {
if(dy > Dy(r))
dy = Dy(r);
n = bpl*dy;
}
a = bufimage(d, 1+4+4*4);
if(a == nil) {
werrstr("unloadimage: %r");
return -1;
}
a[0] = 'r';
BPLONG(a+1, i->id);
BPLONG(a+5, r.min.x);
BPLONG(a+9, r.min.y);
BPLONG(a+13, r.min.x+dx);
BPLONG(a+17, r.min.y+dy);
if(flushimage(d, 0) < 0)
return -1;
if(read(d->fd, data, n) < 0)
return -1;
data += bpl*dy;
r.min.y += dy;
}
return data - start;
}
示例15: resize
void
resize(void)
{
int fd, size = (Dx(screen->r) > Dy(screen->r)) ? Dy(screen->r) + 20 : Dx(screen->r)+20;
fd = open("/dev/wctl", OWRITE);
if(fd >= 0){
fprint(fd, "resize -dx %d -dy %d", size, size);
close(fd);
}
}