当前位置: 首页>>代码示例>>C++>>正文


C++ Dx函数代码示例

本文整理汇总了C++中Dx函数的典型用法代码示例。如果您正苦于以下问题:C++ Dx函数的具体用法?C++ Dx怎么用?C++ Dx使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Dx函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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);
	}
}
开发者ID:grobe0ba,项目名称:plan9front,代码行数:35,代码来源:win.c

示例2: 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;
		}
	}
}
开发者ID:CoryXie,项目名称:nix-os,代码行数:27,代码来源:screenlock.c

示例3: 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);
}
开发者ID:grobe0ba,项目名称:plan9front,代码行数:27,代码来源:glendy.c

示例4: rowresize

void
rowresize(Row *row, Rectangle r)
{
	int i, dx, odx;
	Rectangle r1, r2;
	Column *c;

	dx = Dx(r);
	odx = Dx(row->r);
	row->r = r;
	r1 = r;
	r1.max.y = r1.min.y + font->height;
	textresize(&row->tag, screen, r1);
	r1.min.y = r1.max.y;
	r1.max.y += Border;
	draw(screen, r1, display->black, nil, ZP);
	r.min.y = r1.max.y;
	r1 = r;
	r1.max.x = r1.min.x;
	for(i=0; i<row->ncol; i++){
		c = row->col[i];
		r1.min.x = r1.max.x;
		if(i == row->ncol-1)
			r1.max.x = r.max.x;
		else
			r1.max.x = r1.min.x+Dx(c->r)*dx/odx;
		if(i > 0){
			r2 = r1;
			r2.max.x = r2.min.x+Border;
			draw(screen, r2, display->black, nil, ZP);
			r1.min.x = r2.max.x;
		}
		colresize(c, r1);
	}
}
开发者ID:99years,项目名称:plan9,代码行数:35,代码来源:rows.c

示例5: 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);
	}
}
开发者ID:8l,项目名称:inferno,代码行数:58,代码来源:crect.c

示例6: 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;
	}
}
开发者ID:dancrossnyc,项目名称:harvey,代码行数:61,代码来源:view.c

示例7: 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;
}
开发者ID:aahud,项目名称:harvey,代码行数:9,代码来源:catclock.c

示例8: 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;
}
开发者ID:99years,项目名称:plan9,代码行数:56,代码来源:vgamga4xx.c

示例9: drawnowin

void
drawnowin(int i)
{
	Rectangle r;

	r = Rect(0,0,(Dx(screen->r)-2*MARGIN+PAD)/cols-PAD, font->height);
	r = rectaddpt(rectaddpt(r, Pt(MARGIN+(PAD+Dx(r))*(i/rows),
				MARGIN+(PAD+Dy(r))*(i%rows))), screen->r.min);
	draw(screen, insetrect(r, -1), lightblue, nil, ZP);
}
开发者ID:vrthra,项目名称:9front-tmp,代码行数:10,代码来源:winwatch.c

示例10: 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);
	}

}
开发者ID:grobe0ba,项目名称:plan9front,代码行数:12,代码来源:glendy.c

示例11: drawbar

void
drawbar(void)
{
	int i, j;
	int p;
	char buf[400], bar[200];
	static char lastbar[200];

	if(n > d || n < 0 || d <= 0)
		return;

	i = (Dx(rbar)*n)/d;
	p = (n*100LL)/d;
	if(textmode){
		if(Dx(rbar) > 150){
			rbar.min.x = 0;
			rbar.max.x = 150;
			return;
		}
		bar[0] = '|';
		for(j=0; j<i; j++)
			bar[j+1] = '#';
		for(; j<Dx(rbar); j++)
			bar[j+1] = '-';
		bar[j++] = '|';
		bar[j++] = ' ';
		sprint(bar+j, "%3d%% ", p);
		for(i=0; bar[i]==lastbar[i] && bar[i]; i++)
			;
		memset(buf, '\b', strlen(lastbar)-i);
		strcpy(buf+strlen(lastbar)-i, bar+i);
		if(buf[0])
			write(1, buf, strlen(buf));
		strcpy(lastbar, bar);
		return;
	}

	if(lastp == p && last == i)
		return;

	if(lastp != p){
		sprint(buf, "%d%%", p);
		stringbg(screen, addpt(screen->r.min, Pt(Dx(rbar)-30, 4)), text, ZP, display->defaultfont, buf, light, ZP);
		lastp = p;
	}

	if(last != i){
		draw(screen, Rect(rbar.min.x+last, rbar.min.y, rbar.min.x+i, rbar.max.y),
			dark, nil, ZP);
		last = i;
	}
	flushimage(display, 1);
}
开发者ID:00001,项目名称:plan9port,代码行数:53,代码来源:statusbar.c

示例12: rowadd

Column*
rowadd(Row *row, Column *c, int x)
{
	Rectangle r, r1;
	Column *d;
	int i;

	d = nil;
	r = row->r;
	r.min.y = row->tag.r.max.y+Border;
	if(x<r.min.x && row->ncol>0){	/*steal 40% of last column by default */
		d = row->col[row->ncol-1];
		x = d->r.min.x + 3*Dx(d->r)/5;
	}
	/* look for column we'll land on */
	for(i=0; i<row->ncol; i++){
		d = row->col[i];
		if(x < d->r.max.x)
			break;
	}
	if(row->ncol > 0){
		if(i < row->ncol)
			i++;	/* new column will go after d */
		r = d->r;
		if(Dx(r) < 100)
			return nil;
		draw(screen, r, display->white, nil, ZP);
		r1 = r;
		r1.max.x = min(x, r.max.x-50);
		if(Dx(r1) < 50)
			r1.max.x = r1.min.x+50;
		colresize(d, r1);
		r1.min.x = r1.max.x;
		r1.max.x = r1.min.x+Border;
		draw(screen, r1, display->black, nil, ZP);
		r.min.x = r1.max.x;
	}
	if(c == nil){
		c = emalloc(sizeof(Column));
		colinit(c, r);
		incref(&reffont);
	}else
		colresize(c, r);
	c->row = row;
	c->tag.row = row;
	row->col = realloc(row->col, (row->ncol+1)*sizeof(Column*));
	memmove(row->col+i+1, row->col+i, (row->ncol-i)*sizeof(Column*));
	row->col[i] = c;
	row->ncol++;
	clearmouse();
	return c;
}
开发者ID:AustenConrad,项目名称:plan-9,代码行数:52,代码来源:rows.c

示例13: boxboxresize

static void
boxboxresize(Group *g, Rectangle r)
{
	int rows, cols, ht, wid, i, hpad, wpad;
	Rectangle rr;

	if(debug) fprint(2, "boxboxresize %q %R (%d×%d) min/max %R separation %d\n", g->name, r, Dx(r), Dy(r), g->size, g->separation);
	ht = 0;
	for(i=0; i<g->nkids; i++){
		if (g->kids[i]->size.min.y > ht)
			ht = g->kids[i]->size.min.y;
	}
	if (ht == 0)
		ctlerror("boxboxresize: height");
	rows = Dy(r) / (ht+g->separation);
	hpad = (Dy(r) % (ht+g->separation)) / g->nkids;
	cols = (g->nkids+rows-1)/rows;
	wid = Dx(r) / cols - g->separation;
	for(i=0; i<g->nkids; i++){
		if (g->kids[i]->size.max.x < wid)
			wid = g->kids[i]->size.max.x;
	}
	for(i=0; i<g->nkids; i++){
		if (g->kids[i]->size.min.x > wid)
			wid = g->kids[i]->size.min.x;
	}
	if (wid > Dx(r) / cols)
		ctlerror("can't fit controls in boxbox");
	wpad = (Dx(r) % (wid+g->separation)) / g->nkids;
	rr = rectaddpt(Rect(0,0,wid, ht), addpt(r.min, Pt(g->separation/2, g->separation/2)));
	if(debug) fprint(2, "boxboxresize rows %d, cols %d, wid %d, ht %d, wpad %d, hpad %d\n", rows, cols, wid, ht, wpad, hpad);
	for(i=0; i<g->nkids; i++){
		if(debug) fprint(2, "	%d %q: %R (%d×%d)\n", i, g->kids[i]->name, rr, Dx(rr), Dy(rr));
		_ctlprint(g->kids[i], "rect %R",
			rectaddpt(rr, Pt((wpad+wid+g->separation)*(i/rows), (hpad+ht+g->separation)*(i%rows))));
	}
	g->nseparators = rows + cols - 2;
	g->separators = realloc(g->separators, g->nseparators*sizeof(Rectangle));
	rr = r;
	rr.max.y = rr.min.y + g->separation+hpad;
	for (i = 1; i < rows; i++){
		g->separators[i-1] = rectaddpt(rr, Pt(0, (hpad+ht+g->separation)*i-g->separation-hpad));
		if(debug) fprint(2, "row separation %d [%d]: %R\n", i, i-1, rectaddpt(rr, Pt(0, (hpad+ht+g->separation)*i-g->separation)));
	}
	rr = r;
	rr.max.x = rr.min.x + g->separation+wpad;
	for (i = 1; i < cols; i++){
		g->separators[i+rows-2] = rectaddpt(rr, Pt((wpad+wid+g->separation)*i-g->separation-wpad, 0));
		if(debug) fprint(2, "col separation %d [%d]: %R\n", i, i+rows-2, rectaddpt(rr, Pt((wpad+wid+g->separation)*i-g->separation, 0)));
	}
}
开发者ID:99years,项目名称:plan9,代码行数:51,代码来源:group.c

示例14: geometry

void
geometry(void)
{
	int i, rows;
	Rectangle r;

	rows = (Dy(screen->r)-2*MARGIN+PAD)/(font->height+PAD);

	r = Rect(0,0,(Dx(screen->r)-2*MARGIN), font->height);
	for(i=0; i<nmap; i++)
		map[i].r = rectaddpt(rectaddpt(r, Pt(MARGIN+(PAD+Dx(r))*(i/rows),
					MARGIN+(PAD+Dy(r))*(i%rows))), screen->r.min);

}
开发者ID:aahud,项目名称:harvey,代码行数:14,代码来源:kbmap.c

示例15: sub_image

int sub_image (imageptr iptr, regionptr rptr, imageptr *optr)
{
  int nx,ny,nz, nx1,ny1,nz1, ix,iy,iz, ix0,iy0,iz0;
  size_t np, np1;

  nx  = Nx(iptr);
  ny  = Ny(iptr);
  nz  = Nz(iptr);
  np = nx*ny*nz;
  /* grab the bounding box */
  ix0 = BLC(rptr)[0];
  iy0 = BLC(rptr)[1];
  iz0 = BLC(rptr)[2];
  nx1 = TRC(rptr)[0] - ix0;
  ny1 = TRC(rptr)[1] - iy0;
  nz1 = TRC(rptr)[2] - iz0;
  np1 = nx1*ny1*nz1;

  *optr = (imageptr ) allocate(sizeof(image));
  dprintf (DLEV,"copy_image:Allocated image @ %d size=%d * %d * %d",*optr,nx1,ny1,nz1);
    	
  Frame(*optr) = (real *) allocate(np1*sizeof(real));	
  dprintf (DLEV,"Frame allocated @ %d ",Frame(*optr));
  Nx(*optr) = nx1;
  Ny(*optr) = ny1;
  Nz(*optr) = nz1;
  Xmin(*optr) = Xmin(iptr) + ix0*Dx(iptr);
  Ymin(*optr) = Ymin(iptr) + iy0*Dy(iptr);
  Zmin(*optr) = Zmin(iptr) + iz0*Dz(iptr);
  Dx(*optr) = Dx(iptr);
  Dy(*optr) = Dy(iptr);
  Dz(*optr) = Dz(iptr);
  Namex(*optr) = mystrcpy(Namex(iptr));
  Namey(*optr) = mystrcpy(Namey(iptr));
  Namez(*optr) = mystrcpy(Namez(iptr));
  Xref(*optr) = Xref(iptr) + ix0;
  Yref(*optr) = Yref(iptr) + iy0;
  Zref(*optr) = Zref(iptr) + iz0;
  for (iz=0; iz<nz1; iz++)
    for (iy=0; iy<ny1; iy++)
      for (ix=0; ix<nx1; ix++)
	CubeValue(*optr,ix,iy,iz) = CubeValue(iptr,ix-ix0,iy-iy0,iz-iy0);
  Storage(*optr) = matdef[idef];
  Axis(*optr) = Axis(iptr);
  set_iarray(*optr);
  
  return 1;		/* succes return code  */
}
开发者ID:jobovy,项目名称:nemo,代码行数:48,代码来源:image.c


注:本文中的Dx函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。