Пример #1
0
//
// DrawSelf
//
// Draw the control using currently registered callbacks
//
void ICGrid::DrawSelf(PaintInfo &pi)
{
  // Draw a frame
  DrawCtrlFrame(pi);

  // Do we have a cell iteration callback
  if (cellFunc)
  {
    // Window top left pixel position
    U32 xp1 = pi.client.p0.x;
    U32 yp1 = pi.client.p0.y;

    // Initial pixel positions for each axis (changes for flipping)
    U32 xip = xFlip ? xp1 + gridSize.x * cellSize.x - cellSize.x : xp1;
    U32 yip = yFlip ? yp1 + gridSize.y * cellSize.y - cellSize.y : yp1;

    // Draw the grid
    for (U32 x = 0, px = xip; x < gridSize.x; x++, px = xFlip ? (px - cellSize.x) : (px + cellSize.x))
    {
      for (U32 y = 0, py = yip; y < gridSize.y; y++, py = yFlip ? (py - cellSize.y) : (py + cellSize.y))
      {
        // Get the color from the callback
        Color color = cellFunc(context, x, y);

        // And paint this cell
        IFace::RenderRectangle(ClipRect(px, py, px + cellSize.x, py + cellSize.y), color);
      }
    }

    // Do we have a post-iteration callback
    if (postFunc)
    {
      // Setup paint info
      postPaintInfo = &pi;

      // Trigger the callback
      postFunc(this);

      // Clear data
      postPaintInfo = NULL;
    }

    // Hackville
    if (displaySelected)
    {
      U32 x = selected.x;
      U32 y = selected.y;
      if (xFlip) { x = gridSize.x - x - 1; }
      if (yFlip) { y = gridSize.y - y - 1; }
      U32 xPos = pi.client.p0.x + (x * cellSize.x) + (cellSize.x / 4);
      U32 yPos = pi.client.p0.y + (y * cellSize.y) + (cellSize.y / 4);
      IFace::RenderRectangle(ClipRect(xPos, yPos, xPos + cellSize.x / 2, yPos + cellSize.y / 2), Color(1.0F, 1.0F, 1.0F, 0.5F));
    }
  }
}
Пример #2
0
  //
  // Draw control
  //
  void PrereqTree::DrawSelf(PaintInfo &pi)
  {
    if (constructor.Alive())
    {
      // Draw all the items
      S32 height = pi.client.Height();
      S32 yoffset = height / 2;
      S32 x = point.x;
      S32 y = point.y;

      // Move the client/window areas up to the top left
      Point<S32> offset(pi.client.p1.x, pi.client.p0.y);

      pi.client -= offset;
      pi.window -= offset;

      x -= 30;
      Point<S32> o(x, y);

      pi.client += o;
      pi.window += o;

      controlState |= STATE_HILITE;
      DrawCtrlBackground(pi, GetTexture());
      DrawCtrlFrame(pi);
      DrawCtrlText(pi, type->GetDesc());
      controlState &= ~STATE_HILITE;

      pi.client -= o;
      pi.window -= o;

      IFace::RenderRectangle(ClipRect(point.x - 30, point.y + yoffset, point.x, point.y + yoffset + 1), Color(1.0f, 1.0f, 1.0f, pi.alphaScale), NULL, pi.alphaScale);
      x -= pi.client.Width();

      S32 savey = y;
      S32 bottom = savey;
      Draw(TRUE, pi, x - 30, y, bottom, type);

      // Draw lines
      if (y > savey)
      {
        IFace::RenderRectangle(ClipRect(x - 25, point.y + yoffset, x, point.y + yoffset + 1), Color(1.0f, 1.0f, 1.0f, pi.alphaScale), NULL, pi.alphaScale);
        IFace::RenderRectangle(ClipRect(x - 25, savey + yoffset, x - 24, bottom + yoffset + 1), Color(1.0f, 1.0f, 1.0f, pi.alphaScale), NULL, pi.alphaScale);
      }
    }
    else
    {
      MarkForDeletion();
    }
  }
void PreviewDrawer(ControlRef Ctrl, void *Data)
{
	// Don't need the data arg here
	CrosshairData &Crosshairs = GetCrosshairData();	// An alias for the global crosshair data
	
	// No need for the window context -- it's assumed
	Rect Bounds = {0,0,0,0};
	
	GetControlBounds(Ctrl, &Bounds);
	
	// Get ready to draw!
	PenNormal();
	
	// Draw the background
	RGBForeColor(&BkgdColor);
	PaintRect(&Bounds);
	
	// Clip to inside of box
	ClipRect(&Bounds);
	
	// Draw the crosshairs
	Crosshairs_Render(Bounds);
	
	// Draw the boundary line
	ForeColor(blackColor);
	FrameRect(&Bounds);
}
Пример #4
0
ClipRect PaintLayerClipper::clipRectWithGeometryMapper(
    const ClipRectsContext& context,
    bool isForeground) const {
  DCHECK(m_geometryMapper);
  LayoutRect source(LayoutRect::infiniteIntRect());
  bool success = false;
  const auto* properties = m_layer.layoutObject()->paintProperties();
  PropertyTreeState propertyTreeState =
      properties->localBorderBoxProperties()->propertyTreeState;

  if (isForeground && shouldClipOverflow(context) && properties->overflowClip())
    propertyTreeState.setClip(properties->overflowClip());

  const auto* ancestorProperties =
      context.rootLayer->layoutObject()->paintProperties();
  PropertyTreeState destinationPropertyTreeState =
      ancestorProperties->localBorderBoxProperties()->propertyTreeState;
  if (!context.rootLayer->clipper().shouldRespectOverflowClip(context)) {
    if (ancestorProperties->overflowClip())
      destinationPropertyTreeState.setClip(ancestorProperties->overflowClip());
  }
  FloatRect clippedRectInRootLayerSpace =
      m_geometryMapper->mapToVisualRectInDestinationSpace(
          FloatRect(source), propertyTreeState, destinationPropertyTreeState,
          success);
  DCHECK(success);
  return ClipRect(LayoutRect(clippedRectInRootLayerSpace));
}
Пример #5
0
int main(int argc, char **argv) {
    int w, h, fontsize;
    VGint x, cx, cy, cw, ch, midy, speed;
    char *message = "Now is the time for all good men to come to the aid of the party";
    char done[3];

    init(&w, &h);
    speed = 15;
    midy = (VGfloat) h / 2;
    fontsize = w / 50;
    cx = 0.0;
    ch = fontsize * 2;
    cw = w;
    cy = midy - (ch / 2);

    // scroll the text, only in the clipping rectangle
    for (x = 0; x < cw+speed; x += speed) {
        Start(w, h);
        Background(255, 255, 255);
        Fill(0,0,0,.2);
        Rect(cx, cy, cw, ch);
        ClipRect(cx, cy, cw, ch);
        Translate(x, cy + (fontsize / 2));
        Fill(0, 0, 0, 1);
        Text(0, 0, message, SansTypeface, fontsize);
        ClipEnd();
        End();
    }
    fgets(done, 2, stdin); // press [Return] when done
    finish();
    exit(0);
}
Пример #6
0
void QTCode_ForceMovieRedraw(Movie theMovie) 
{
	OSErr 		err = noErr;
	Rect		movieRect;
	RgnHandle	clipRegion = NULL;

	
		if (theMovie == NULL) goto bail;
	
		clipRegion = NewRgn();
		if (clipRegion == NULL) goto bail;
		
		GetClip(clipRegion);
		GetMovieBox(theMovie, &movieRect); 
		ClipRect(&movieRect);
	
		UpdateMovie(theMovie);
		MoviesTask(theMovie, 0);
	
		SetClip(clipRegion);
	
			/* Closure. Clean up if we have handles. */
	bail:	
	
		if	(clipRegion != NULL)
		{
			DisposeRgn(clipRegion);
		}
}
Пример #7
0
PRIVATE PicHandle
pict_from_gworld (GWorldPtr gp, int *lenp)
{
  PicHandle retval;

  if (!gp)
    retval = NULL;
  else
    {
      Rect pict_frame;
      PixMapHandle pm;

      pm = GetGWorldPixMap (gp);
      pict_frame = PIXMAP_BOUNDS (pm);
      retval = OpenPicture (&pict_frame);
      if (retval)
	{
	  ClipRect (&pict_frame);
	  HLock ((Handle) pm);
	  CopyBits ((BitMap *) STARH (pm), PORT_BITS_FOR_COPY (thePort),
		    &pict_frame, &pict_frame, srcCopy, NULL);
	  HUnlock ((Handle) pm);
	  ClosePicture ();
	}
    }
  return retval;
}
Пример #8
0
static
void resize_window(void)
{
  double max_width, max_height;
  int width, height;
  Rect wRect;

  max_width = MWIDTH;
  max_height = max_width * p->sheight / p->swidth;

  gks_fit_ws_viewport(p->viewport, max_width, max_height, 0.075);
  width = nint((p->viewport[1] - p->viewport[0]) / max_width * p->swidth);
  height = nint((p->viewport[3] - p->viewport[2]) / max_height * p->sheight);

  if (p->width != width || p->height != height)
    {
      p->width = width;
      p->height = height;

      SizeWindow(p->win, width, height, TRUE);

      GetWindowPortBounds(p->win, &wRect);
      ClipRect(&wRect);
    }
}
Пример #9
0
static void centerstring (Rect r, Str255 s) {
	
	/*
	draw the string in the current font, size and style, centered inside
	the indicated rectangle.
	*/
	
	short rh = r.bottom - r.top;
	short rw = r.right - r.left;
	short h, v;
	FontInfo fi;
	
	GetFontInfo (&fi);
	
	ellipsize (s, rw); /*make sure it fits inside the rectangle, width-wise*/
	
	h = r.left + ((rw - StringWidth (s)) / 2);
	
	v = r.top + ((rh - (fi.ascent + fi.descent)) / 2) + fi.ascent;
	
	MoveTo (h, v);
	
	ClipRect (&r);
	
	DrawString (s);
	} /*centerstring*/
Пример #10
0
Файл: ugView.c Проект: rolk/ug
static void SaveToPICT (SFReply *reply)
{
  Rect MyPicFrame ;
  CQDProcs MyPicProcs,*SavePtr ;
  OSErr error ;
  long LongZero, LongCount ;
  short Counter ;
  CGrafPtr theCGrafPort;
  WindowPtr theWindow;
  OpenCPicParams myOpenCPicParams;

  /* get my window */
  theWindow = myWindow.theWindow;
  theCGrafPort = (CGrafPtr) theWindow;

  error = FSOpen(reply->fName, reply->vRefNum, &FileSys_RefNR ) ;
  SetStdCProcs ( &MyPicProcs ) ;
  SavePtr = (CQDProcs *) theWindow->grafProcs;
  theWindow->grafProcs   = (QDProcs *) (&MyPicProcs) ;
  MyPicProcs.putPicProc  = NewQDPutPicProc(MyPutPicData) ;

  LongZero   = 0 ;
  LongCount  = 4 ;

  PicCounter = sizeof(Picture) ;
  for (Counter=1 ; Counter <= 128+sizeof(Picture) ; Counter++ )
    error = FSWrite(FileSys_RefNR, &LongCount, &LongZero );
  error = SetFPos(FileSys_RefNR, fsFromStart, 512+sizeof(Picture)) ;

  SetPort((GrafPtr)(theWindow));
  MyPicFrame = ((GrafPtr)(theWindow))->portRect;
  MyPicFrame.right = MyPicFrame.right-16;
  MyPicFrame.bottom = MyPicFrame.bottom-16;
  MyPicHand  = NULL ;
  myOpenCPicParams.srcRect        = MyPicFrame;
  myOpenCPicParams.hRes           = cHRes;
  myOpenCPicParams.vRes           = cVRes;
  myOpenCPicParams.version        = -2;
  myOpenCPicParams.reserved1      = 0;
  myOpenCPicParams.reserved2      = 0;
  MyPicHand  = OpenCPicture ( &myOpenCPicParams );
  ClipRect(&MyPicFrame);

  /* draw picture */
  RefreshCommand();

  ClosePicture() ;

  /* close File */
  error = SetFPos(FileSys_RefNR, fsFromStart, 512) ;
  LongCount = sizeof(Picture) ;
  error = FSWrite(FileSys_RefNR, &LongCount, (void *) (*MyPicHand) );
  error = FSClose(FileSys_RefNR) ;

  KillPicture(MyPicHand);
  theWindow->grafProcs   = (QDProcs *) SavePtr ;

  return;
}
Пример #11
0
// Blit image from DirectDraw surface to Windows DIB section.
//
void DDImage::DDBlitImageDIB(CDIBDraw *DIBDraw,SLONG XPos,SLONG YPos,DWORD Flags)
{
//	Flags = 0;
//	Flags |= SF_TEXTUREFLIPX;
//	Flags |= SF_TEXTUREFLIPY;
//	Flags |= SF_ROT90;

#if(1)
	DDBlitFRImageDIB(DIBDraw,XPos,YPos,Flags);
#else
	if((Flags&SF_TEXTUREFLIPX) && (Flags&SF_TEXTUREFLIPY)) {
		DDBlitImageDIBFlipXY(DIBDraw,XPos,YPos);
		return;
	}
	if(Flags&SF_TEXTUREFLIPX) {
		DDBlitImageDIBFlipX(DIBDraw,XPos,YPos);
		return;
	}
	if(Flags&SF_TEXTUREFLIPY) {
		DDBlitImageDIBFlipY(DIBDraw,XPos,YPos);
		return;
	}
	if(Flags&SF_TEXTUREROTMASK) {
		switch(Flags&SF_TEXTUREROTMASK) {
			case	SF_ROT90:
				DDBlitImageDIBRot90(DIBDraw,XPos,YPos);
				break;

			case	SF_ROT180:
				break;

			case	SF_ROT270:
				break;
		}
		return;
	}

    RECT    src;
    RECT    dst;

	setRectWH(&src,m_SourceX,m_SourceY,m_Width,m_Height);
	setRectWH(&dst,x,y,m_Width,m_Height);

	if(ClipRect(DIBDraw,XPos,YPos,src,dst) & CLIP_GONE) {
		return;
	}

	HDC hdc=m_DirectDrawView->DDGetSurfaceDC(m_Surface);

	BitBlt(DIBDraw->GetDIBDC(), dst.left, 
								dst.top, 
								dst.right-dst.left, 
								dst.bottom-dst.top,
							    hdc , src.left, src.top, SRCCOPY);


	m_DirectDrawView->DDReleaseSurfaceDC(m_Surface,hdc);
#endif
}
Пример #12
0
  //
  // Draw 
  //
  void PrereqTree::Draw(Bool first, PaintInfo &pi, S32 x, S32 &y, S32 &bottom, UnitObjType *type)
  {
    // Get the prereqs
    for (UnitObjTypeList::Iterator t(&type->GetPrereqs().Get()); *t; t++)
    {
      UnitObjType *type = **t;

      // Only add it if we ...
      // Don't Have It
      if (
        !Prereq::HaveType(team, type) ||
        (first && constructor->MissingUpgrade(type)))
      {
        pi.client += Point<S32>(x, y);
        pi.window += Point<S32>(x, y);

        DrawCtrlBackground(pi, GetTexture());
        DrawCtrlFrame(pi);
        DrawCtrlText(pi, type->GetDesc());

        S32 height = pi.client.Height();
        S32 yoffset = height / 2;

        // Draw horizontal line
        IFace::RenderRectangle(ClipRect(x, y + yoffset, x + 5, y + 1 + yoffset), Color(1.0f, 1.0f, 1.0f, pi.alphaScale), NULL, pi.alphaScale);

        pi.client -= Point<S32>(x, y);
        pi.window -= Point<S32>(x, y);

        bottom = y;

        y += height + 5;
        S32 savey = y;
        S32 bottom = savey;

        // Draw children
        Draw(FALSE, pi, x - 10, y, bottom, type);

        // Draw vertical line (if neccesary)
        if (y > savey)
        {
          IFace::RenderRectangle(ClipRect(x - 5, savey - 5, x - 4, bottom + yoffset + 1), Color(1.0f, 1.0f, 1.0f, pi.alphaScale), NULL, pi.alphaScale);
        }
      }
    }
  }
Пример #13
0
static void DisableDrawing ( void ) {

	Rect	nullRect = { 0, 0, 0, 0 };

	GetClip ( gSaveClip );
	ClipRect ( &nullRect );
	
	return;
	} /*DisableDrawing*/
Пример #14
0
Файл: MacGraph.c Проект: rolk/ug
void DrawInfoBox (WINDOWID win, const char *info)
{
  WindowPtr theMacWindow;
  Rect r,box,WinRect;
  CGrafPtr myPort;
  Rect myClipRect;
  short w;
  GRAPH_WINDOW *gw;
  Str255 pstr;

  gw = (GRAPH_WINDOW *)win;
  theMacWindow = MAC_WIN(gw);
  /* set port */
  myPort = GetWindowPort(theMacWindow);
  SetPort(myPort);

  GetPortBounds(myPort,&WinRect);

  PmForeColor(1);               /* black */
  GetPortBounds(myPort,&r);

  /* info box */
  SetRect(&box,r.left+1,r.bottom-14,r.right-121,r.bottom);

  /* set clipping region to info box */
  ClipRect(&box);

  EraseRect(&box);

  CopyCStringToPascal(info,pstr);
  w = StringWidth(pstr);
  MoveTo((box.left+box.right)/2-w/2,box.bottom-3);
  TextSize(9);
  DrawString(pstr);

  /* adjust clipping rectangle again to plottable area */
  myClipRect.left   = gw->Local_LL[0];
  myClipRect.right  = gw->Local_UR[0];
  myClipRect.bottom = gw->Local_LL[1];
  myClipRect.top    = gw->Local_UR[1];

  ClipRect(&myClipRect);
}
Пример #15
0
CBActiveRect::CBActiveRect(CBGame* inGame):CBBase(inGame)
{
	CBPlatform::SetRectEmpty(&m_Rect);
	m_Owner = NULL;
	m_Frame = NULL;
	m_Region = NULL;
	m_ZoomX = 100;
	m_ZoomY = 100;
	m_OffsetX = m_OffsetY = 0;
	ClipRect();
}
Пример #16
0
void DDImage::DDBlitImageDIBFlipY(CDIBDraw *DIBDraw,SLONG x,SLONG y)
{
    RECT    src;
    RECT    dst;
	DWORD ClipFlags;

	setRectWH(&src,m_SourceX,m_SourceY,m_Width,m_Height);
	setRectWH(&dst,x,y,m_Width,m_Height);

	RECT pcSrc = src;		// Pre-clipped source rectangle.

	if( (ClipFlags = ClipRect(DIBDraw,x,y,src,dst)) & CLIP_GONE) {
		return;
	}

// Since were Y flipped we need to adjust the clipped source rect.
	if(ClipFlags & CLIP_TOP) {
		src.top = pcSrc.top;
	}
	if(ClipFlags & CLIP_BOTTOM) {
		src.top += m_Height-(src.bottom-pcSrc.top);
	}

	int Width = dst.right-dst.left;
	int Height = dst.bottom-dst.top;

    SURFACEDESC ddsd;
    HRESULT ddrval;

    ddsd.dwSize = sizeof(ddsd);
    while ((ddrval = m_Surface->Lock(NULL, &ddsd, 0, NULL)) == DDERR_WASSTILLDRAWING);
	if(ddrval != DD_OK) {
		DisplayError(ddrval,__FILE__,__LINE__,0);
	}

	m_Surface->Unlock(NULL);

	ULONG SourcePitch = ddsd.lPitch/2;
	ULONG DestPitch = DIBDraw->GetDIBWidth();

	UWORD *Dest = (UWORD*)DIBDraw->GetDIBBits();
	Dest += dst.left + ((dst.top + (Height-1))*DestPitch);
	UWORD *Source = (UWORD*)ddsd.lpSurface;
	Source += src.left + (src.top*SourcePitch);

	for(int iy=0; iy<Height; iy++) {
		for(int ix=0; ix<Width; ix++){
			*(Dest+ix) = *(Source+ix);
		}

		Source += SourcePitch;
		Dest -= DestPitch;
	}
}
Пример #17
0
CBActiveRect::CBActiveRect(CBGame* inGame, CBObject* Owner, CBSubFrame* Frame, int X, int Y, int Width, int Height, float ZoomX, float ZoomY, bool Precise):CBBase(inGame)
{
	m_Owner = Owner;
	m_Frame = Frame;
	CBPlatform::SetRect(&m_Rect, X, Y, X+Width, Y+Height);
	m_ZoomX = ZoomX;
	m_ZoomY = ZoomY;
	m_Precise = Precise;
	m_Region = NULL;
	m_OffsetX = m_OffsetY = 0;
	ClipRect();
}
Пример #18
0
static
void set_clip_rect(int tnr)
{
  Rect *rect;

  if (gkss->clip == GKS_K_CLIP)
    rect = p->rect + tnr;
  else
    rect = p->rect;

  ClipRect(rect);
}
Пример #19
0
Файл: MacGraph.c Проект: rolk/ug
INT Mac_UpdateOutput (WINDOWID win, INT tool)
{
  GRAPH_WINDOW *gw;
  WindowPtr theWindow;
  Rect myClipRect,*portRect = nil;

  gw = (GRAPH_WINDOW *) win;
  theWindow = MAC_WIN(gw);

  gw->currTool = tool;

  SetPort(GetWindowPort(theWindow));

  /* identify clipping rect with port */
  GetPortBounds(GetWindowPort(theWindow),portRect);
  ClipRect(portRect);

  BeginUpdate(theWindow);
  /* leave this out: uginterface will manage
     EraseRgn(((GrafPtr)theWindow)->visRgn);*/
  EndUpdate(theWindow);

  /* adjust cursor */
  if (theWindow == FrontWindow())
    ActivateMacWin (gw,tool);

  DrawGrowIcon(theWindow);
  DrawToolBox(gw,tool);

  /* reset clipping rectangle */
  myClipRect.left   = portRect->left;
  myClipRect.right  = portRect->right  - SCROLL_BAR;
  myClipRect.bottom = portRect->bottom - SCROLL_BAR;
  myClipRect.top    = portRect->top;

  ClipRect(&myClipRect);

  return (0);
}
Пример #20
0
void DDImage::DDBlitImageDIBRot90(CDIBDraw *DIBDraw,SLONG x,SLONG y)
{
    RECT    src;
    RECT    dst;
	DWORD ClipFlags;

// Can only rotate square images.
	ASSERT(m_Width == m_Height);

	setRectWH(&src,m_SourceX,m_SourceY,m_Width,m_Height);
	setRectWH(&dst,x,y,m_Width,m_Height);

	if( (ClipFlags = ClipRect(DIBDraw,x,y,src,dst)) & CLIP_GONE) {
		return;
	}

	int Width = dst.right-dst.left;
	int Height = dst.bottom-dst.top;

//	if(Width!=Height) return;
	if(Width > Height) return;

    SURFACEDESC ddsd;
    HRESULT ddrval;

    ddsd.dwSize = sizeof(ddsd);
    while ((ddrval = m_Surface->Lock(NULL, &ddsd, 0, NULL)) == DDERR_WASSTILLDRAWING);
	if(ddrval != DD_OK) {
		DisplayError(ddrval,__FILE__,__LINE__,0);
	}

	m_Surface->Unlock(NULL);

	ULONG SourcePitch = ddsd.lPitch/2;
	ULONG DestPitch = DIBDraw->GetDIBWidth();

	UWORD *Dest = (UWORD*)DIBDraw->GetDIBBits();
	Dest += dst.left + (dst.top*DestPitch) + (Width-1);
	UWORD *Source = (UWORD*)ddsd.lpSurface;
	Source += src.left + (src.top*SourcePitch);

	for(int iy=0; iy<Height; iy++) {
		for(int ix=0; ix<Width; ix++) {
			*(Dest+ix*DestPitch) = *(Source+ix);
		}

		Source += SourcePitch;
		Dest--;
	}
}
Пример #21
0
CBActiveRect::CBActiveRect(CBGame* inGame, CBObject* Owner, CBRegion* Region, int OffsetX, int OffsetY):CBBase(inGame)
{
	m_Owner = Owner;	
	m_Region = Region;
	CBPlatform::CopyRect(&m_Rect, &Region->m_Rect);
	CBPlatform::OffsetRect(&m_Rect, -OffsetX, -OffsetY);
	m_ZoomX = 100;
	m_ZoomY = 100;
	m_Precise = true;
	m_Frame = NULL;	
	ClipRect();
	m_OffsetX = OffsetX;
	m_OffsetY = OffsetY;
}
Пример #22
0
//
// DrawCell
//
// Only to be called from a post-iteration callback
//
void ICGrid::DrawCell(U32 x, U32 y, Color c)
{
  // Ensure we're in the right mode and have valid values
  if (postPaintInfo && (x < gridSize.x) && (y < gridSize.y))
  {
    // Adjust for flipped axis
    if (xFlip) { x = gridSize.x - x - 1; }
    if (yFlip) { y = gridSize.y - y - 1; }

    U32 xPos = postPaintInfo->client.p0.x + (x * cellSize.x);
    U32 yPos = postPaintInfo->client.p0.y + (y * cellSize.y);

    IFace::RenderRectangle(ClipRect(xPos, yPos, xPos + cellSize.x, yPos + cellSize.y), c);
  }
}
Пример #23
0
void CEngineSurface :: drawTexturedRect( int x0, int y0, int x1, int y1 )
{
	vpoint_t rect[2];
	vpoint_t clippedRect[2];

	InitVertex( rect[0], x0, y0, 0, 0 );
	InitVertex( rect[1], x1, y1, 1, 1 );

	// fully clipped?
	if( !ClipRect( rect[0], rect[1], &clippedRect[0], &clippedRect[1] ))
		return;	

	VGUI_SetupDrawingImage( _drawColor );	
	VGUI_DrawQuad( &clippedRect[0], &clippedRect[1] );
}
Пример #24
0
//--------------------------------------------------------------------------------
//	@	WindowManager::UpdateBuffer()
//--------------------------------------------------------------------------------
//		Add and Image to the buffer
//--------------------------------------------------------------------------------
void WindowManager::UpdateBuffer(const Image& img, uint32 x, uint32 y)
{
	//Get portion of the screen to render to
	SDL_Rect rect;
	rect.x = x;
	rect.y = y;
	rect.h = img.h();
	rect.w = img.w();

	//Clip if necessary
	if (!ClipRect(rect, ww, wh))
		return;

	//Update texture
	SDL_UpdateTexture(sdlTexture, &rect, img.pixels(),
		img.pitch() );

}	//End: WindowManager::ApplyToBuffer()
Пример #25
0
void CEngineSurface :: drawFilledRect( int x0, int y0, int x1, int y1 )
{
	vpoint_t rect[2];
	vpoint_t clippedRect[2];

	if( _drawColor[3] >= 255 ) return;

	InitVertex( rect[0], x0, y0, 0, 0 );
	InitVertex( rect[1], x1, y1, 0, 0 );

	// fully clipped?
	if( !ClipRect( rect[0], rect[1], &clippedRect[0], &clippedRect[1] ))
		return;	

	VGUI_SetupDrawingRect( _drawColor );	
	VGUI_EnableTexture( false );
	VGUI_DrawQuad( &clippedRect[0], &clippedRect[1] );
	VGUI_EnableTexture( true );
}
Пример #26
0
PRBool
SimplePluginInstance::StartDraw(nsPluginWindow* window)
{
    NP_Port* port;
    Rect clipRect;
    RGBColor  col;
	
    if (window == NULL)
        return FALSE;
    port = (NP_Port*) window->window;
    if (window->clipRect.left < window->clipRect.right)
    {
	/* Preserve the old port */
        GetPort((GrafPtr*)&gOldPort);
        SetPort((GrafPtr)port->port);
	/* Preserve the old drawing environment */
        gSavePort.portRect = port->port->portRect;
        gSavePort.txFont = port->port->txFont;
        gSavePort.txFace = port->port->txFace;
        gSavePort.txMode = port->port->txMode;
        gSavePort.rgbFgColor = port->port->rgbFgColor;
        gSavePort.rgbBkColor = port->port->rgbBkColor;
        GetClip(gSavePort.clipRgn);
	/* Setup our drawing environment */
        clipRect.top = window->clipRect.top + port->porty;
        clipRect.left = window->clipRect.left + port->portx;
        clipRect.bottom = window->clipRect.bottom + port->porty;
        clipRect.right = window->clipRect.right + port->portx;
        SetOrigin(port->portx,port->porty);
        ClipRect(&clipRect);
        clipRect.top = clipRect.left = 0;
        TextSize(12);
        TextFont(geneva);
        TextMode(srcCopy);
        col.red = col.green = col.blue = 0;
        RGBForeColor(&col);
        col.red = col.green = col.blue = 65000;
        RGBBackColor(&col);
        return TRUE;
    }
    else
        return FALSE;
}
Пример #27
0
// New doMyDeviceLoop, now works with multiple monitors
void doMyDeviceLoop()
{
	int				depth;
	Rect			gDeviceRect;
	Rect			intersectingRect;
	GDHandle		gDevice;
	//WindowRecord	*windowRec = (WindowRecord *)gWindow;
	WindowPtr		windowRec = gWindow;
	Rect			windowRect; //= (**windowRec->contRgn).rgnBBox;
	RgnHandle		rgnHandle = NewRgn();
	
	GetWindowRegion(windowRec, kWindowContentRgn, rgnHandle);
	GetRegionBounds(rgnHandle, &windowRect);

	// Get the handle to the first device in the list. 
	gDevice = GetDeviceList();

	// Loop through all the devices in the list. 
	while (gDevice != nil)
	{
		// Get the device's gdRect  */
		gDeviceRect = (**gDevice).gdRect;
		depth = (**(**gDevice).gdPMap).pixelSize;

		// Check if the app's window rect intersects the device's, and if it 
		// does, set the clip region's rect to the intersection, then DRAW! 
		if (SectRect( &windowRect, &gDeviceRect, &intersectingRect ))
		{
			// The intersectingRect is in global coords. Convert to local 
			GlobalToLocal((Point *)&intersectingRect.top);
			GlobalToLocal((Point *)&intersectingRect.bottom);

			ClipRect( &intersectingRect );
			doDraw( depth, &intersectingRect );
		}

		// Get the next device in the list. 
		gDevice = GetNextDevice( gDevice );
	}
	
	DisposeRgn(rgnHandle);
}
Пример #28
0
//--------------------------------------------------------------------------------
//	@	ViewportManager::SetMasks()
//--------------------------------------------------------------------------------
//		Set all z-masks for each viewport. Does not apply masks, just 
//		calculates them.
//--------------------------------------------------------------------------------
void ViewportManager::SetMasks()
{
	//Adjust all viewports
	for (int32 i = 0; i < viewportList.size()-1; ++i)
	{
		//Clear current masks
		viewportList[i].masks.clear();

		//Adjust all viewports
		for (int32 j = i+1; j < viewportList.size(); ++j)
		{
			DgRect temp((viewportList[j].viewport.x() - viewportList[i].viewport.x()),
				(viewportList[j].viewport.y() - viewportList[i].viewport.y()),
				viewportList[j].viewport.w(), viewportList[j].viewport.h());

			if (!ClipRect(temp, viewportList[i].viewport.w(), viewportList[i].viewport.h()))
				viewportList[i].masks.push_back(temp);
		}
	}

}	//End: ViewportManager::SetMasks()
Пример #29
0
ClipRect PaintLayerClipper::applyOverflowClipToBackgroundRectWithGeometryMapper(
    const ClipRectsContext& context,
    const ClipRect& clip) const {
  const LayoutObject& layoutObject = *m_layer.layoutObject();
  FloatRect clipRect(clip.rect());
  if (shouldClipOverflow(context)) {
    LayoutRect layerBoundsWithVisualOverflow =
        layoutObject.isLayoutView()
            ? toLayoutView(layoutObject).viewRect()
            : toLayoutBox(layoutObject).visualOverflowRect();
    toLayoutBox(layoutObject)
        .flipForWritingMode(
            // PaintLayer are in physical coordinates, so the overflow has to be
            // flipped.
            layerBoundsWithVisualOverflow);
    mapLocalToRootWithGeometryMapper(context, layerBoundsWithVisualOverflow);
    clipRect.intersect(FloatRect(layerBoundsWithVisualOverflow));
  }

  return ClipRect(LayoutRect(clipRect));
}
Пример #30
0
/*	DisplayDialogCmd(theDialog, dlogItemNo, cmd)

	Displays the command in an IGOR-style dialog. See GBLoadWaveDialog.c
	for an example.
	
	dlogItemNo is the item number of the dialog item in which the command
	is to be displayed. On the Macintosh, this must be a user item. On Windows,
	it must be an EDITTEXT item.

	Thread Safety: DisplayDialogCmd is not thread-safe.
*/
void
DisplayDialogCmd(DialogPtr theDialog, int dlogItemNo, const char* cmd)
{
	WindowRef theWindow;
	CGrafPtr thePort;
	Rect box;
	int font, size;
	int lineHeight;
	FontInfo info;
	RgnHandle saveClipRgnH;
	
	theWindow = GetDialogWindow(theDialog);
	thePort = GetWindowPort(theWindow);
	
	font = GetPortTextFont(thePort);		// Save text characteristics.
	size = GetPortTextSize(thePort);

	TextFont(kFontIDMonaco);
	TextSize(9);
	GetFontInfo(&info);
	lineHeight = info.ascent + info.descent + info.leading;
	
	GetDBox(theDialog, dlogItemNo, &box);
	saveClipRgnH = NewRgn();
	if (saveClipRgnH != NULL) {
		GetClip(saveClipRgnH);
		ClipRect(&box);
		InsetRect(&box, 2, 2);
		EraseRect(&box);
		if (*cmd != 0) {
			MoveTo(box.left+2, box.top + info.ascent + 2);
			DrawDialogCmd(cmd, lineHeight);
		}
		SetClip(saveClipRgnH);
		DisposeRgn(saveClipRgnH);
	}

	TextFont(font);									// Restore font, size, style.
	TextSize(size);
}