示例#1
0
/*----------------------------------------------------------------------------------------------
	Change selection as the mouse moves to a new color cell (button)
----------------------------------------------------------------------------------------------*/
void IconComboPopup::OnMouseMove(UINT nFlags, int xp, int yp)
{
    Point pt(xp, yp);

    if (m_fIgnoreButtonUp)
    {
        Point ptT(pt);
        Rect rc;
        ::ClientToScreen(m_hwnd, &ptT);
        ::GetWindowRect(m_hwnd, &rc);
        if (rc.Contains(ptT))
            m_fIgnoreButtonUp = false;
    }

    // Get the row and column from the point (GetTableIndexFromRowCol returns -1 if the mouse
    // if not over a button.
    int ivalNew = GetTableIndexFromRowCol(GetRowFromPt(pt), GetColFromPt(pt));

    // In range? If not, default and exit
    if (ivalNew < 0)
        return;

    // OK - we have the row and column of the current selection
    // Has the row/col selection changed? If yes, then redraw old and new cells.
    if (ivalNew != m_ivalHot)
        ChangeSelection(ivalNew);
}
示例#2
0
static void
RepeatOrStretchSurface(DrawTarget& aDT, SourceSurface* aSurface,
                       const Rect& aDest, const Rect& aSrc, Rect& aSkipRect)
{
  if (aSkipRect.Contains(aDest)) {
    return;
  }

  if ((!aDT.GetTransform().IsRectilinear() &&
       aDT.GetBackendType() != BackendType::CAIRO) ||
      (aDT.GetBackendType() == BackendType::DIRECT2D)) {
    // Use stretching if possible, since it leads to less seams when the
    // destination is transformed. However, don't do this if we're using cairo,
    // because if cairo is using pixman it won't render anything for large
    // stretch factors because pixman's internal fixed point precision is not
    // high enough to handle those scale factors.
    // Calling FillRect on a D2D backend with a repeating pattern is much slower
    // than DrawSurface, so special case the D2D backend here.
    aDT.DrawSurface(aSurface, aDest, aSrc);
    return;
  }

  SurfacePattern pattern(aSurface, ExtendMode::REPEAT,
                         Matrix::Translation(aDest.TopLeft() - aSrc.TopLeft()),
                         Filter::GOOD, RoundedToInt(aSrc));
  aDT.FillRect(aDest, pattern);
}
示例#3
0
int		LinkTimeControl::HitTestFCurves( ParamDimensionBase *dim, TrackHitTab& hits, Rect& rcHit, Rect& rcGraph,			
			float tzoom, int tscroll, float vzoom, int vscroll, DWORD flags )
{
	int h = rcGraph.h()-1;

	bool hit = false;

	const int n = NumKeys();
	for ( int i=0; i<n; ++i )
	{
		BOOL sel = IsKeySelected( i );
		if ( ( flags & HITTRACK_SELONLY ) && !sel )
			continue;
		if ( ( flags & HITTRACK_UNSELONLY ) && sel )
			continue;
		TimeValue t = GetKeyTime( i );
		int x = TimeToScreen( t, tzoom, tscroll );
		float val;
		Interval valid;
		GetValue( t, &val, valid );
		int y = ValueToScreen( dim->Convert(val), h, vzoom, vscroll );
		if ( rcHit.Contains( IPoint2( x, y ) ) )
		{
			hit = true;
			TrackHitRecord rec( i, 0 );
			hits.Append( 1, &rec );
			if ( flags & HITTRACK_ABORTONHIT )
				break;
		}
	}

	return hit ?  HITCURVE_KEY : HITCURVE_NONE;
}
示例#4
0
static void
RepeatOrStretchMirroredSurface(DrawTarget* aDT, SourceSurface* aSurface,
                               const Rect& aDest, const Rect& aSrc,
                               const Rect& aSkipRect, Float aScaleX, Float aScaleY)
{
  if (aSkipRect.Contains(aDest)) {
    return;
  }

  if (ShouldStretchSurface(aDT, aSurface)) {
    aScaleX *= aDest.width / aSrc.width;
    aScaleY *= aDest.height / aSrc.height;
    DrawMirroredRect(aDT, aSurface, aDest, aSrc.TopLeft(), aScaleX, aScaleY);
    return;
  }

  SurfacePattern pattern(aSurface, ExtendMode::REPEAT,
                         Matrix::Scaling(aScaleX, aScaleY)
                           .PreTranslate(-aSrc.TopLeft())
                           .PostTranslate(
                             aScaleX < 0 ? aDest.XMost() : aDest.x,
                             aScaleY < 0 ? aDest.YMost() : aDest.y),
                         SamplingFilter::GOOD, RoundedToInt(aSrc));
  aDT->FillRect(aDest, pattern);
}
void
DrawTargetTiled::StrokeRect(const Rect& aRect, const Pattern& aPattern, const StrokeOptions &aStrokeOptions, const DrawOptions& aDrawOptions)
{
  Rect deviceRect = mTransform.TransformBounds(aRect);
  Margin strokeMargin = MaxStrokeExtents(aStrokeOptions, mTransform);
  Rect outerRect = deviceRect;
  outerRect.Inflate(strokeMargin);
  Rect innerRect;
  if (mTransform.IsRectilinear()) {
    // If rects are mapped to rects, we can compute the inner rect
    // of the stroked rect.
    innerRect = deviceRect;
    innerRect.Deflate(strokeMargin);
  }
  for (size_t i = 0; i < mTiles.size(); i++) {
    if (mTiles[i].mClippedOut) {
      continue;
    }
    Rect tileRect(mTiles[i].mTileOrigin.x,
                  mTiles[i].mTileOrigin.y,
                  mTiles[i].mDrawTarget->GetSize().width,
                  mTiles[i].mDrawTarget->GetSize().height);
    if (outerRect.Intersects(tileRect) && !innerRect.Contains(tileRect)) {
      mTiles[i].mDrawTarget->StrokeRect(aRect, aPattern, aStrokeOptions, aDrawOptions);
    }
  }
}
示例#6
0
BOOL CArcView::IntersectsWithRect(const Rect& rectangle)
{
	Point topLeft(rectangle.GetLeft(), rectangle.GetTop());
	Point topRight(rectangle.GetRight(), rectangle.GetTop());
	Point bottomLeft(rectangle.GetLeft(), rectangle.GetBottom());
	Point bottomRight(rectangle.GetRight(), rectangle.GetBottom());

	Point currentPoint(*pathPoints.begin());
	for(auto it=pathPoints.begin() + 1; it != pathPoints.end(); ++it)
	{
		if(rectangle.Contains(currentPoint))
			return TRUE;
		if(Geometry::LinesIntersect(topLeft, topRight, currentPoint, *it))
			return TRUE;
		if(Geometry::LinesIntersect(topLeft, bottomLeft, currentPoint, *it))
			return TRUE;
		if(Geometry::LinesIntersect(bottomLeft, bottomRight, currentPoint, *it))
			return TRUE;
		if(Geometry::LinesIntersect(topRight, bottomRight, currentPoint, *it))
			return TRUE;

		currentPoint = *it;
	}

	return FALSE;
}
示例#7
0
void Ctrl::DoMouseFB(int event, Point p, int zdelta, CParser& cp)
{
	ReadKeyMods(cp);
	MousePos = p;
	int a = event & ACTION;
	if(a == UP && Ctrl::ignoreclick) {
		EndIgnore();
		return;
	}
	else
	if(a == DOWN && ignoreclick)
		return;
	LLOG("### Mouse event: " << event << " position " << p << " zdelta " << zdelta << ", capture " << Upp::Name(captureCtrl));
	if(captureCtrl)
		MouseEventFB(captureCtrl->GetTopCtrl(), event, p, zdelta);
	else
		for(int i = topctrl.GetCount() - 1; i >= 0; i--) {
			Ptr<Ctrl> t = topctrl[i];
			Rect rr = t->GetRect();
			if(rr.Contains(p)) {
				MouseEventFB(t, event, p, zdelta);
				return;
			}
		}
	Ctrl *desktop = GetDesktop();
	if(desktop) {
		desktop->DispatchMouse(event, p, zdelta);
		desktop->PostInput();
	}
}
示例#8
0
Rect Rect::Subtract(const Rect& rect) const {
  // boundary cases:
  if (!Intersects(rect))
    return *this;
  if (rect.Contains(*this))
    return Rect();

  int32_t rx = x();
  int32_t ry = y();
  int32_t rr = right();
  int32_t rb = bottom();

  if (rect.y() <= y() && rect.bottom() >= bottom()) {
    // complete intersection in the y-direction
    if (rect.x() <= x()) {
      rx = rect.right();
    } else {
      rr = rect.x();
    }
  } else if (rect.x() <= x() && rect.right() >= right()) {
    // complete intersection in the x-direction
    if (rect.y() <= y()) {
      ry = rect.bottom();
    } else {
      rb = rect.y();
    }
  }
  return Rect(rx, ry, rr - rx, rb - ry);
}
示例#9
0
Point
DSWindow::MapPoint(const Point& pt) const
{
	const Rect
		bounds(0, MainScreenHeight, MainScreenWidth, MainScreenHeight << 1);

	return bounds.Contains(pt) ? pt - bounds.GetPoint() : Point::Invalid;
}
示例#10
0
CVariable *CBlockUnit::GetIOPort(UINT x, UINT y)
{
  Rect rect;

  if (x == 0 && y == 0)
  {
    return NULL;
  }

  // Check for input ports
  for (int i = 0; i < m_vInput.size(); i++)
  {
    // Assign selection box rect
    rect.X = m_vInput[i]->m_ptPort.X - 5;
    rect.Y = m_vInput[i]->m_ptPort.Y - 5;
    rect.Width  = 10;
    rect.Height = 10;

    // Check if pos in box
    if (rect.Contains(x, y))
    {
      return m_vInput[i];
    }
  }

  // Check for output ports
  for (int i = 0; i < m_vOutput.size(); i++)
  {
    // Assign selection box rect
    rect.X = m_vOutput[i]->m_ptPort.X - 5;
    rect.Y = m_vOutput[i]->m_ptPort.Y - 5;
    rect.Width  = 10;
    rect.Height = 10;

    // Check if pos in box
    if (rect.Contains(x, y))
    {
      return m_vOutput[i];
    }
  }

  return NULL;
}
示例#11
0
static void
DrawCorner(DrawTarget* aDT, SourceSurface* aSurface,
           const Rect& aDest, const Rect& aSrc, const Rect& aSkipRect)
{
  if (aSkipRect.Contains(aDest)) {
    return;
  }

  aDT->DrawSurface(aSurface, aDest, aSrc);
}
示例#12
0
DockCont *DockWindow::FindDockTarget(DockCont &dc, int &dock)
{
	Point p = GetMousePos();
	Rect r = GetScreenView();
	DockCont *target = NULL;
	int align = DOCK_NONE;

	dock = DOCK_NONE;

	if (r.Contains(p)) {
		dock = GetPointAlign(p, r, true, true, true);
		if (dock != DOCK_NONE && dockpane[dock].IsVisible())
			dock = DOCK_NONE;
	}
	else {
		target = GetMouseDockTarget();
		if (target) {
			r = target->GetScreenRect();
			dock = GetDockAlign(*target);
			align = GetPointAlign(p, r, IsTabbing(), IsTB(dock), !IsTB(dock));
		}
		else
			return NULL;
	}

	if (dock != DOCK_NONE && (!dc.IsDockAllowed(dock)
		 || IsPaneAnimating(dock) || IsFrameAnimating(dock))
		 || (dock == DOCK_NONE && !target)) {
		dock = DOCK_NONE;
		return NULL;
	}

	// Prepare for highlight
	if (target) {
		GetHighlightCtrl().bounds = GetAlignBounds(align, r, IsTabbing(), IsTB(dock), !IsTB(dock));
		if (align == DOCK_NONE)
			dock = DOCK_NONE; // Tabbing
		// The following code handles the case of an insertion between two docked controls. In this case we must set
		//  the highlight bounds to be a union of the bounds from each control. Very ugly.
		if (dock != DOCK_NONE) {
			Ctrl *c = IsTL(align) ? target->GetPrev() : target->GetNext();
			if (c) {
				int opal = align > 1 ? align-2 : align+2;
				GetHighlightCtrl().bounds.Union(GetAlignBounds(opal, c->GetScreenRect(), IsTabbing()));
			}
			target = IsTL(align) ? target : dynamic_cast<DockCont*>(target->GetNext());
		}

	}
	else if (dock != DOCK_NONE)
		GetHighlightCtrl().bounds = GetAlignBounds(dock, r, true);

	return target;
}
示例#13
0
static void
DrawMirroredCorner(DrawTarget* aDT, SourceSurface* aSurface,
                   const Rect& aDest, const Point& aSrc,
                   const Rect& aSkipRect, Float aScaleX, Float aScaleY)
{
  if (aSkipRect.Contains(aDest)) {
    return;
  }

  DrawMirroredRect(aDT, aSurface, aDest, aSrc, aScaleX, aScaleY);
}
示例#14
0
bool Ctrl::DispatchMouseIn(int act, int zd)
{
	Point p = GetMousePos();
	Rect r = GetScreenRect();
	if(r.Contains(p)) {
		p -= r.TopLeft();
		DispatchMouse(act, p, zd);
		return true;
	}
	return false;
}
示例#15
0
/*
 * Docking Interface helpers
*/
DockCont *DockWindow::GetMouseDockTarget()
{
	Point mp = GetMousePos();
	for (int i = 0; i < 4; i++) {
		if (dockpane[i].IsShown()) {
			Rect r = dockpane[i].GetScreenRect();
			if (r.Contains(mp))
				return dynamic_cast<DockCont *>(dockpane[i].ChildFromPoint(mp -= r.TopLeft()));
		}
	}
	return NULL;
}
示例#16
0
BOOL CBlockUnit::OverTitle(UINT x, UINT y)
{
  Rect rect;

  // Build the size box
  rect.X = m_rRect.X;
  rect.Y = m_rRect.Y;
  rect.Width  = m_rRect.Width;
  rect.Height = 20;

  // Return check value
  return rect.Contains(x, y);
}
示例#17
0
BOOL CBlockUnit::OverSizeBox(UINT x, UINT y)
{
  Rect rect;

  // Build the size box
  rect.X = m_rRect.GetRight() - 8;
  rect.Y = m_rRect.GetBottom() - 8;
  rect.Width  = 6;
  rect.Height = 6;

  // Return check value
  return rect.Contains(x, y);
}
示例#18
0
nsIFrame*
nsSVGImageFrame::GetFrameForPoint(const gfxPoint& aPoint)
{
  if (!(GetStateBits() & NS_STATE_SVG_CLIPPATH_CHILD) && !GetHitTestFlags()) {
    return nullptr;
  }

  Rect rect;
  SVGImageElement *element = static_cast<SVGImageElement*>(mContent);
  element->GetAnimatedLengthValues(&rect.x, &rect.y,
                                   &rect.width, &rect.height, nullptr);

  if (!rect.Contains(ToPoint(aPoint))) {
    return nullptr;
  }

  // Special case for raster images -- we only want to accept points that fall
  // in the underlying image's (scaled to fit) native bounds.  That region
  // doesn't necessarily map to our <image> element's [x,y,width,height] if the
  // raster image's aspect ratio is being preserved.  We have to look up the
  // native image size & our viewBox transform in order to filter out points
  // that fall outside that area.  (This special case doesn't apply to vector
  // images because they don't limit their drawing to explicit "native
  // bounds" -- they have an infinite canvas on which to place content.)
  if (StyleDisplay()->IsScrollableOverflow() && mImageContainer) {
    if (mImageContainer->GetType() == imgIContainer::TYPE_RASTER) {
      int32_t nativeWidth, nativeHeight;
      if (NS_FAILED(mImageContainer->GetWidth(&nativeWidth)) ||
          NS_FAILED(mImageContainer->GetHeight(&nativeHeight)) ||
          nativeWidth == 0 || nativeHeight == 0) {
        return nullptr;
      }
      Matrix viewBoxTM =
        SVGContentUtils::GetViewBoxTransform(rect.width, rect.height,
                                             0, 0, nativeWidth, nativeHeight,
                                             element->mPreserveAspectRatio);
      if (!nsSVGUtils::HitTestRect(viewBoxTM,
                                   0, 0, nativeWidth, nativeHeight,
                                   aPoint.x - rect.x, aPoint.y - rect.y)) {
        return nullptr;
      }
    }
  }

  return this;
}
示例#19
0
bool SystemDraw::ExcludeClipOp(const Rect& r)
{
    GuiLock __;
#ifdef PLATFORM_WINCE
    int q = ExcludeClipRect(handle, r.left, r.top, r.right, r.bottom);
#else
    LTIMING("ExcludeClip");
    if(r.Contains(drawingclip))
        drawingclip = Rect(0, 0, 0, 0);
    Rect rr = LPtoDP(r);
    HRGN hrgn = ::CreateRectRgnIndirect(rr);
    int q = ::ExtSelectClipRgn(handle, hrgn, RGN_DIFF);
    ASSERT(q != ERROR);
    ::DeleteObject(hrgn);
#endif
    return q == SIMPLEREGION || q == COMPLEXREGION;
}
示例#20
0
void MultiButton::SyncInfo()
{
	if((HasMouse() || info.HasMouse()) && display &&
	   (GetMouseFlags() & (K_MOUSELEFT|K_MOUSERIGHT|K_MOUSEMIDDLE)) == 0) {
		Point p = GetMouseViewPos();
		NilDraw nw;
		Rect r = Paint0(nw, true);
		if(r.Contains(p)) {
			Value v = convert->Format(value);
			int cm = DPI(2);
			r.left -= cm;
			r.right += cm;
			info.Set(this, r, value, display, SColorText, SColorPaper, 0, DPI(2));
			return;
		}
	}
	info.Cancel();
}
示例#21
0
static void
RepeatOrStretchSurface(DrawTarget* aDT, SourceSurface* aSurface,
                       const Rect& aDest, const Rect& aSrc, const Rect& aSkipRect)
{
  if (aSkipRect.Contains(aDest)) {
    return;
  }

  if (ShouldStretchSurface(aDT, aSurface)) {
    aDT->DrawSurface(aSurface, aDest, aSrc);
    return;
  }

  SurfacePattern pattern(aSurface, ExtendMode::REPEAT,
                         Matrix::Translation(aDest.TopLeft() - aSrc.TopLeft()),
                         SamplingFilter::GOOD, RoundedToInt(aSrc));
  aDT->FillRect(aDest, pattern);
}
示例#22
0
    Rect Rect::Subtract(const Rect& rect) const
    {
        // 边界情况:
        if(!Intersects(rect))
        {
            return *this;
        }
        if(rect.Contains(*this))
        {
            return Rect();
        }

        int rx = x();
        int ry = y();
        int rr = right();
        int rb = bottom();

        if(rect.y()<=y() && rect.bottom()>=bottom())
        {
            // y方向完全相交.
            if(rect.x() <= x())
            {
                rx = rect.right();
            }
            else
            {
                rr = rect.x();
            }
        }
        else if(rect.x()<=x() && rect.right()>=right())
        {
            // x方向完全相交.
            if(rect.y() <= y())
            {
                ry = rect.bottom();
            }
            else
            {
                rb = rect.y();
            }
        }
        return Rect(rx, ry, rr-rx, rb-ry);
    }
示例#23
0
nsIFrame*
nsSVGInnerSVGFrame::GetFrameForPoint(const gfxPoint& aPoint)
{
  NS_ASSERTION(!NS_SVGDisplayListHitTestingEnabled() ||
               (mState & NS_FRAME_IS_NONDISPLAY),
               "If display lists are enabled, only hit-testing of non-display "
               "SVG should take this code path");

  if (StyleDisplay()->IsScrollableOverflow()) {
    Rect clip;
    static_cast<nsSVGElement*>(mContent)->
      GetAnimatedLengthValues(&clip.x, &clip.y,
                              &clip.width, &clip.height, nullptr);
    if (!clip.Contains(ToPoint(aPoint))) {
      return nullptr;
    }
  }

  return nsSVGInnerSVGFrameBase::GetFrameForPoint(aPoint);
}
示例#24
0
BOOL CCircleView::IntersectsWithRect(const Rect& rectangle)
{
	Point center(position);

	double edgeCenterDistance = INT_MAX;
	std::vector<Point> rectCorners;
	Point topLeft(rectangle.GetLeft(), rectangle.GetTop());
	Point topRight(rectangle.GetRight(), rectangle.GetTop());
	Point bottomLeft(rectangle.GetLeft(), rectangle.GetBottom());
	Point bottomRight(rectangle.GetRight(), rectangle.GetBottom());

	rectCorners.push_back(topLeft);
	rectCorners.push_back(topRight);
	rectCorners.push_back(bottomLeft);
	rectCorners.push_back(bottomRight);

	//Le centre du cercle est-il dans le rectangle ?
	if(rectangle.Contains(center)) return TRUE;

	//Un coin du rectangle est-il dans le cercle ?
	for(auto it=rectCorners.begin(); it!=rectCorners.end(); ++it)
		if(Geometry::Distance(*it, center) < radius) return TRUE;

	//Un côté du rectangle coupe-t-il dans le cercle ?
	if(topLeft.X < center.X && center.X < topRight.X
		&& Geometry::LinePointDistance(topLeft, topRight, center) < radius)
		return TRUE;
	if(topLeft.Y < center.Y && center.Y < bottomLeft.Y
		&& Geometry::LinePointDistance(topLeft, bottomLeft, center) < radius)
		return TRUE;
	if(bottomLeft.X < center.X && center.X < bottomRight.X
		&& Geometry::LinePointDistance(bottomLeft, bottomRight, center) < radius)
		return TRUE;
	if(topRight.Y < center.Y && center.Y < bottomRight.Y
		&& Geometry::LinePointDistance(topRight, bottomRight, center) < radius)
		return TRUE;

	return FALSE;
}
示例#25
0
bool AlphaMask::Compatible(const Transform &inTransform,
                           const Rect &inExtent, const Rect &inVisiblePixels,
                           int &outTX, int &outTY )
{
   int tx,ty;
   if  ( (!mMatrix.IsIntTranslation(*inTransform.mMatrix,tx,ty)) || (mScale9!=*inTransform.mScale9) )
      return false;

   if (mAAFactor!=inTransform.mAAFactor)
      return false;

   // Translate our cached pixels to this new position ...
   Rect translated = mRect.Translated(tx,ty);
   if (translated.Contains(inVisiblePixels))
   {
      outTX = tx;
      outTY = ty;
      return true;
   }

   return false;
}