示例#1
0
//***********************************************************************************************************
void CBCGPBaseVisualCtrl::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

	if (m_pGM == NULL)
	{
		m_pGM = CBCGPGraphicsManager::CreateInstance();
	}

	if (m_pGM == NULL)
	{
		return;
	}

	double dblMemDCScale = m_pGM->IsSupported(BCGP_GRAPHICS_MANAGER_SCALING) ? 1.0 : m_dblScale;
	
	CBCGPMemDC memDC (dc, this, 0, dblMemDCScale);
	CDC* pDC = &memDC.GetDC ();

	CRect rectClip(0, 0, 0, 0);
	if (!IsDirty())
	{
		dc.GetClipBox(rectClip);
	}

	DoPaint(pDC, rectClip);
}
示例#2
0
const DisplayItemClip*
WithoutRoundedCorners(nsDisplayListBuilder* aBuilder, const DisplayItemClip* aClip)
{
  if (!aClip) {
    return nullptr;
  }
  DisplayItemClip rectClip(*aClip);
  rectClip.RemoveRoundedCorners();
  return aBuilder->AllocateDisplayItemClip(rectClip);
}
示例#3
0
double computeOverlapPP(double *ix, double *iy,
                        double minX, double maxX, 
			double minY, double maxY,
			double pixelArea)
{
   int    npts;
   double area;

   double nx[100];
   double ny[100];

   double xp[4], yp[4];


   /* Clip the input pixel polygon with the */
   /* output pixel range                    */

   npts = rectClip(4, ix, iy, nx, ny, minX, minY, maxX, maxY);


   /* If no points, it may mean that     */
   /* the output is completely contained */
   /* in the input                       */

   if(npts < 3)
   {
      xp[0] = minX; yp[0] = minY;
      xp[1] = maxX; yp[1] = minY;
      xp[2] = maxX; yp[2] = maxY;
      xp[3] = minX; yp[3] = maxY;

      if(ptInPoly(ix[0], iy[0], 4, xp, yp))
      {
	 area = pixelArea;
	 return area;
      }

      return 0.;
   }

   area = polyArea(npts, nx, ny) * pixelArea;

   return(area);
}
void ArrayCtrl::onRender(GFXSurface *sfc, Point2I offset, const Box2I &updateRect)
{
   //make sure we have a parent
   if (! parent) return;
   
   int i, j;
   RectI headerClip;
   RectI clipRect(updateRect.fMin, updateRect.fMax);
   clipRect.lowerR -= 1; // inset by 1 for GFX
   
   Point2I parentRect = parent->localToGlobalCoord(Point2I(0, 0));
   
   //if we have column headings
   if (headerDim.y > 0)
   {
      headerClip.upperL.x =   parentRect.x + headerDim.x;
      headerClip.upperL.y =   parentRect.y;
      headerClip.lowerR.x =   clipRect.lowerR.x;
      headerClip.lowerR.y =   parentRect.y + headerDim.y;
      
      if (rectClip(&headerClip, &clipRect))
      {
         sfc->setClipRect(&headerClip);
               
         //now render the header
         onRenderColumnHeaders(sfc, offset, parentRect, headerDim);
         
         clipRect.upperL.y = headerClip.lowerR.y;
      }
      offset.y += headerDim.y;
   }
   
   //save the original for clipping the row headers
   RectI origClipRect(clipRect.upperL, clipRect.lowerR);
   
   //if we have row headings 
   if (headerDim.x > 0)
   {
      clipRect.upperL.x = max(clipRect.upperL.x, parentRect.x + headerDim.x);
      offset.x += headerDim.x;
   }
   
   for(j = 0; j < size.y; j++)
   {
      if((j + 1) * cellSize.y + offset.y < updateRect.fMin.y)
         continue;
      if(j * cellSize.y + offset.y >= updateRect.fMax.y)
         break;
         
      //render the header
      if (headerDim.x > 0)
      {
         headerClip.upperL.x =   parentRect.x;
         headerClip.lowerR.x =   parentRect.x + headerDim.x;
         headerClip.upperL.y = offset.y + j * cellSize.y;
         headerClip.lowerR.y = offset.y + (j + 1) * cellSize.y;
         if(rectClip(&headerClip, &origClipRect))
         {
            sfc->setClipRect(&headerClip);
            
            //render the row header
            onRenderRowHeader(sfc, Point2I(0, offset.y + j * cellSize.y),
                              Point2I(parentRect.x, offset.y + j * cellSize.y),
                              headerDim, Point2I(0, j));
         }
      }
      
      //render the cells for the row
      for(i = 0; i < size.x; i++)
      {
         if((i + 1) * cellSize.x + offset.x < updateRect.fMin.x)
            continue;
         if(i * cellSize.x + offset.x >= updateRect.fMax.x)
            break;
         int cellx = offset.x + i * cellSize.x;
         int celly = offset.y + j * cellSize.y;

         RectI cellClip(cellx, celly, 
            cellx + cellSize.x - 1, celly + cellSize.y - 1);
         
         if(rectClip(&cellClip, &clipRect))
         {
            sfc->setClipRect(&cellClip);
            onRenderCell(sfc, Point2I(cellx, celly), Point2I(i, j), 
               i == selectedCell.x && j == selectedCell.y,
               i == mouseOverCell.x && j == mouseOverCell.y);
         }
      }
   }
}
void TextEdit::DrawText(GFXSurface *sfc)
{
   //first update the cursor if the text is scrolling
   if (dragHit)
   {
      if ((scrollDir < 0) && (cursorPos > 0))
      {
         cursorPos--;
      }
      else if ((scrollDir > 0) && (cursorPos < (int)strlen(text)))
      {
         cursorPos++;
      }
   }

   //set the clip rect
   // to the intersection of the current clip rect and the 
   // text clip rect
   RectI clipi = textClipRect;

   if(!rectClip(&clipi, sfc->getClipRect()))
      return;

   sfc->setClipRect(&clipi);
                  
   bool focused =  (root->getFirstResponder() == this);

   GFXFont *normFont = (!active && (bool)hFontDisabled) ? hFontDisabled : hFont;

   if ((bool)normFont)
   {
      // now draw the text
      Int32 txt_w = normFont->getStrWidth(text) + 3;
      Int32 txt_h = normFont->getHeight();
      Point2I cursorStart, cursorEnd;
      textOffset.y = textClipRect.upperL.y + (((textClipRect.lowerR.y - textClipRect.upperL.y) - txt_h) >> 1) + textVPosDelta;
      if ((textOffset.x == 65535) || (txt_w < (textClipRect.lowerR.x - textClipRect.upperL.x)))
      {
         textOffset.x = textClipRect.upperL.x + 3;
      }
      
      // calculate the cursor
      if (focused)
      {
         int tempWidth;
         char temp = text[cursorPos];
         text[cursorPos] = '\0';
         tempWidth = normFont->getStrWidth(text);
         cursorStart.x = textOffset.x + tempWidth;
         text[cursorPos] = temp;
         cursorEnd.x = cursorStart.x;
         cursorStart.y = textClipRect.upperL.y;
         //cursorEnd.y = cursorStart.y + (textClipRect.lowerR.y - textClipRect.upperL.y) - 8;
         cursorEnd.y = textClipRect.lowerR.y;
         
         if (cursorStart.x < (textClipRect.upperL.x))
         {
            //textOffset.x += (3 + textClipRect.upperL.x - cursorStart.x);
            cursorStart.x = 3 + textClipRect.upperL.x;
            textOffset.x = cursorStart.x - tempWidth;
            cursorEnd.x = cursorStart.x;
         }
         else if (cursorStart.x > textClipRect.lowerR.x)
         {
            //textOffset.x -= (3 + cursorStart.x - textClipRect.lowerR.x);
            cursorStart.x = textClipRect.lowerR.x - 3;
            textOffset.x = cursorStart.x - tempWidth;
            cursorEnd.x = cursorStart.x;
         }
      }
      
      //draw the text
      if ((! (bool)hFontHL) || (! focused))
      {
         blockStart = blockEnd = 0;
      }
      
      //also verify the block start/end
      if ((blockStart > int(strlen(text))) || (blockEnd > int(strlen(text))) || (blockStart > blockEnd))
      {
         blockStart = blockEnd = 0;
      }
      
      char temp;
      Point2I tempOffset = textOffset;
      //draw the portion before the highlite
      if (blockStart > 0)
      {
         temp = text[blockStart];
         text[blockStart] = '\0';
         sfc->drawText_p(normFont, &tempOffset, text); 
         tempOffset.x += normFont->getStrWidth(text) + 1;
         text[blockStart] = temp;
      }
      
      //draw the hilited portion
      if (blockEnd > 0)
      {
         temp = text[blockEnd];
         text[blockEnd] = '\0';
         Int32 highlightWidth = hFontHL->getStrWidth(&text[blockStart]);
         
         if (highlightColor)
         {
            RectI hr(tempOffset.x, textClipRect.upperL.y, tempOffset.x + highlightWidth, textClipRect.lowerR.y);
            sfc->drawRect2d_f(&hr, highlightColor);
         }
         sfc->drawText_p(hFontHL, &tempOffset, &text[blockStart]);
         tempOffset.x += highlightWidth + 1;
         text[blockEnd] = temp;
      }
      
      //draw the portion after the highlite
      sfc->drawText_p(normFont, &tempOffset, &text[blockEnd]);
      
      //draw the cursor      
      if (focused && cursorOn)
      {
         sfc->drawLine2d(&cursorStart, &cursorEnd, cursorColor);
      }
   }
示例#6
0
void TopPane::UpdateBits()
{
/* ORIGINAL ALLEGIANCE VERSION.
	ZEnter("TopPane::UpdateBits()");
    if (m_bNeedPaint) {
        ZTrace("m_bNeedPaint == true");
        if (CalcPaint()) {
            m_bNeedPaint = true;
            m_bPaintAll = true;
        }

        ZTrace("after CalcPaint() m_bNeedPaint ==" + ZString(m_bNeedPaint));
        ZTrace("after CalcPaint() m_bPaintAll  ==" + ZString(m_bPaintAll ));
        m_bPaintAll |= g_bPaintAll;
        InternalPaint(m_psurface);
        m_bNeedPaint = false;
    }
    ZExit("TopPane::UpdateBits()");*/


    ZEnter("TopPane::UpdateBits()");
	{
		HRESULT hr;
		bool bRenderTargetRequired;
		PrivateSurface* pprivateSurface; CastTo(pprivateSurface, m_psurface);
		bRenderTargetRequired = pprivateSurface->GetSurfaceType().Test(SurfaceTypeRenderTarget() ) == true;

		if( bRenderTargetRequired == true )
		{
			TEXHANDLE hTexture = pprivateSurface->GetTexHandle( );
			_ASSERT( hTexture != INVALID_TEX_HANDLE );
			hr = CVRAMManager::Get()->PushRenderTarget( hTexture );
		}

		ZTrace("m_bNeedPaint == true");
        CalcPaint(); 
        m_bNeedPaint = true;
        m_bPaintAll = true;

        ZTrace("after CalcPaint() m_bPaintAll  ==" + ZString(m_bPaintAll ));

		WinPoint offset( 0, 0 );

		// Call InternalPaint() with the child offset and parent size as params and create initial clipping rect.
		WinRect rectClip(	0, 
							0, 
							(int) m_psurface->GetSize().X(),
							(int) m_psurface->GetSize().Y() );

		m_bPaintAll |= g_bPaintAll;
        InternalPaint( m_psurface );
        m_bNeedPaint = false;

		if( bRenderTargetRequired == true )
		{
			CVRAMManager::Get()->PopRenderTarget( );
		}
    }
    ZExit("TopPane::UpdateBits()");

/*	{
        ZTrace("m_bNeedPaint == true");
		CalcPaint();
		m_bNeedPaint = true;
		m_bPaintAll = true;

        ZTrace("after CalcPaint() m_bNeedPaint ==" + ZString(m_bNeedPaint));
        ZTrace("after CalcPaint() m_bPaintAll  ==" + ZString(m_bPaintAll ));
        m_bPaintAll |= g_bPaintAll;

//		localOffset.SetY( localOffset.Y() - (int)m_psurface->GetSize().Y() );
//		localOffset += globalOffset;
		WinPoint offset( localOffset );

		// Remove offset now.
		offset.SetY( offset.Y() - (int)m_psurface->GetSize().Y() );

		// Call InternalPaint() with the child offset and parent size as params and create initial clipping rect.
		WinRect rectClip(	offset.X(), 
							offset.Y(), 
							offset.X() + (int) m_psurface->GetSize().X(),
							offset.Y() + (int) m_psurface->GetSize().Y() );
   
		// m_psurface is a dummy surface. Store the context.
		InternalPaint( m_psurface, offset, rectClip );
        m_bNeedPaint = false;
    }

    ZExit("TopPane::UpdateBits()");*/
}