예제 #1
0
파일: srvutil.c 프로젝트: EPiCS/reconos_v2
/*
 * Draw the border of a window if there is one.
 * Note: To allow the border to be drawn with the correct clipping,
 * we temporarily grow the size of the window to include the border.
 */
void GsDrawBorder(GR_WINDOW *wp)
{
	GR_COORD	lminx;		/* left edge minimum x */
	GR_COORD	rminx;		/* right edge minimum x */
	GR_COORD	tminy;		/* top edge minimum y */
	GR_COORD	bminy;		/* bottom edge minimum y */
	GR_COORD	topy;		/* top y value of window */
	GR_COORD	boty;		/* bottom y value of window */
	GR_SIZE		width;		/* original width of window */
	GR_SIZE		height;		/* original height of window */
	GR_SIZE		bs;		/* border size */

	bs = wp->bordersize;
	if (bs <= 0)
		return;

	width = wp->width;
	height = wp->height;
	lminx = wp->x - bs;
	rminx = wp->x + width;
	tminy = wp->y - bs;
	bminy = wp->y + height;
	topy = wp->y;
	boty = bminy - 1;
 
	wp->x -= bs;
	wp->y -= bs;
	wp->width += (bs * 2);
	wp->height += (bs * 2);
	wp->bordersize = 0;

	clipwp = NULL;
	GsSetClipWindow(wp, NULL, 0);
	curgcp = NULL;
	GdSetMode(GR_MODE_COPY);
	GdSetForeground(GdFindColor(wp->bordercolor));

	if (bs == 1) {
		GdLine(wp->psd, lminx, tminy, rminx, tminy, TRUE);
		GdLine(wp->psd, lminx, bminy, rminx, bminy, TRUE);
		GdLine(wp->psd, lminx, topy, lminx, boty, TRUE);
		GdLine(wp->psd, rminx, topy, rminx, boty, TRUE);
	} else {
		GdFillRect(wp->psd, lminx, tminy, width + bs * 2, bs);
		GdFillRect(wp->psd, lminx, bminy, width + bs * 2, bs);
		GdFillRect(wp->psd, lminx, topy, bs, height);
		GdFillRect(wp->psd, rminx, topy, bs, height);
	}

	/*
	 * Restore the true window size.
	 * Forget the currently clipped window since we messed it up.
	 */
	wp->x += bs;
	wp->y += bs;
	wp->width -= (bs * 2);
	wp->height -= (bs * 2);
	wp->bordersize = bs;
	clipwp = NULL;
}
예제 #2
0
BOOL WINAPI
LineTo(HDC hdc, int x, int y)
{
	HWND		hwnd;
	POINT		beg, end;

	hwnd = MwPrepareDC(hdc);
	if(!hwnd)
		return FALSE;

	beg.x = hdc->pt.x;
	beg.y = hdc->pt.y;
	end.x = x;
	end.y = y;
	if(MwIsClientDC(hdc)) {
		ClientToScreen(hwnd, &beg);
		ClientToScreen(hwnd, &end);
	}

	/* draw line in current pen color*/
	if(hdc->pen->style != PS_NULL) {
		GdSetForegroundColor(hdc->psd, hdc->pen->color);
		/* don't draw last point*/
		GdLine(hdc->psd, beg.x, beg.y, end.x, end.y, FALSE);
	}
	hdc->pt.x = x;
	hdc->pt.y = y;
	return TRUE;
}
예제 #3
0
/* draw line segments by connecting passed points*/
BOOL WINAPI
Polyline(HDC hdc, CONST POINT *lppt, int cPoints)
{
	HWND		hwnd;
	POINT		beg, end;

	if(cPoints <= 1)
		return FALSE;

	hwnd = MwPrepareDC(hdc);
	if(!hwnd)
		return FALSE;

	if(hdc->pen->style == PS_NULL)
		return TRUE;

	/* draw line in current pen color*/
	GdSetForegroundColor(hdc->psd, hdc->pen->color);

	beg = *lppt++;
	if(MwIsClientDC(hdc))
		ClientToScreen(hwnd, &beg);
	while(--cPoints > 0) {
		end = *lppt++;
		if(MwIsClientDC(hdc))
			ClientToScreen(hwnd, &end);

		/* don't draw last point*/
		GdLine(hdc->psd, beg.x, beg.y, end.x, end.y, FALSE);

		beg = end;
	}
	return TRUE;
}
예제 #4
0
파일: devpoly.c 프로젝트: OPSF/uClinux
/**
 * Draw a polygon in the foreground color, applying clipping if necessary.
 * The polygon is only closed if the first point is repeated at the end.
 * Some care is taken to plot the endpoints correctly if the current
 * drawing mode is XOR.  However, internal crossings are not handled
 * correctly.
 *
 * @param psd Drawing surface.
 * @param count Number of points in polygon.
 * @param points The array of points.
 */
void
GdPoly(PSD psd, int count, MWPOINT *points)
{
  MWCOORD firstx;
  MWCOORD firsty;
  MWBOOL didline;

  if (count < 2)
	  return;
  firstx = points->x;
  firsty = points->y;
  didline = FALSE;

  while (count-- > 1) {
	if (didline && (gr_mode == MWMODE_XOR))
		drawpoint(psd, points->x, points->y);
	/* note: change to drawline*/
	GdLine(psd, points[0].x, points[0].y, points[1].x, points[1].y, TRUE);
	points++;
	didline = TRUE;
  }
  if (gr_mode == MWMODE_XOR) {
	  points--;
	  if (points->x == firstx && points->y == firsty)
		drawpoint(psd, points->x, points->y);
  }
  GdFixCursor(psd);
}
예제 #5
0
int test_engine()
{
  MWCOORD x1,x2,y1,y2;
  unsigned long mask=0;
  int count=0;
  int y;

  psd = GdOpenScreen();
  if(psd==NULL) {
    syscall_puts("GdOpenScreen error\n");
    return 0;
  }

  GdSetForegroundPixelVal(psd, 7);
  GdSetBackgroundPixelVal(psd, 0);
  GdSetDash(&mask, &count);

  x1=100; x2=540; y1=100; y2= 380;
  GdLine(psd, x1, y1, x2, y1, 0);
  GdLine(psd, x2, y1, x2, y2, 0);
  GdLine(psd, x1, y2, x2, y2, 0);
  GdLine(psd, x1, y1, x1, y2, 0);

  for(y=0;y<8;y++) {
    GdSetForegroundPixelVal(psd, y);
    GdLine(psd, x1, y1+y, x2, y1+y, 0);
  }

  GdSetForegroundPixelVal(psd, 7);
  GdLine(psd, x1, y1, x2, y2, 0);

  syscall_wait(1000);
  
  GdCloseScreen(psd);

  return 0;
}