Ejemplo n.º 1
0
void CSplashContainer::Draw(const TRect & /*aRect*/)const
{
  CWindowGc &gc = SystemGc();

  gc.SetBrushStyle(CGraphicsContext::ENullBrush);
  gc.SetBrushColor(KRgbBlack);
  gc.DrawRect(Rect());

  TPoint topLeft(KTopLeftX, KTopLeftY);
  TSize bitmapSize(KSizeWidth, KSizeHeight);
  gc.DrawBitmap(TRect(topLeft, bitmapSize), iLogoBitmap);
}
Ejemplo n.º 2
0
RECT MeaCircleTool::GetRegion()
{
    int radius = m_circle.GetRadius();

    CPoint topLeft(m_center.x - radius, m_center.y - radius);
    CPoint bottomRight(m_center.x + radius, m_center.y + radius);
    CRect rect(topLeft, bottomRight);

    rect.InflateRect(0, 0, 1, 1);

    return rect;
}
Ejemplo n.º 3
0
bool SVGInlineTextBox::nodeAtPoint(HitTestResult& result,
                                   const HitTestLocation& locationInContainer,
                                   const LayoutPoint& accumulatedOffset,
                                   LayoutUnit,
                                   LayoutUnit) {
  // FIXME: integrate with InlineTextBox::nodeAtPoint better.
  ASSERT(!isLineBreak());

  PointerEventsHitRules hitRules(PointerEventsHitRules::SVG_TEXT_HITTESTING,
                                 result.hitTestRequest(),
                                 getLineLayoutItem().style()->pointerEvents());
  bool isVisible =
      getLineLayoutItem().style()->visibility() == EVisibility::Visible;
  if (isVisible || !hitRules.requireVisible) {
    if (hitRules.canHitBoundingBox ||
        (hitRules.canHitStroke &&
         (getLineLayoutItem().style()->svgStyle().hasStroke() ||
          !hitRules.requireStroke)) ||
        (hitRules.canHitFill &&
         (getLineLayoutItem().style()->svgStyle().hasFill() ||
          !hitRules.requireFill))) {
      LayoutRect rect(topLeft(), LayoutSize(logicalWidth(), logicalHeight()));
      rect.moveBy(accumulatedOffset);
      if (locationInContainer.intersects(rect)) {
        LineLayoutSVGInlineText lineLayoutItem =
            LineLayoutSVGInlineText(this->getLineLayoutItem());
        const SimpleFontData* fontData =
            lineLayoutItem.scaledFont().primaryFont();
        DCHECK(fontData);
        if (!fontData)
          return false;

        DCHECK(lineLayoutItem.scalingFactor());
        float baseline = fontData->getFontMetrics().floatAscent() /
                         lineLayoutItem.scalingFactor();
        FloatPoint floatLocation = FloatPoint(locationInContainer.point());
        for (const SVGTextFragment& fragment : m_textFragments) {
          FloatQuad fragmentQuad = fragment.boundingQuad(baseline);
          if (fragmentQuad.containsPoint(floatLocation)) {
            lineLayoutItem.updateHitTestResult(
                result,
                locationInContainer.point() - toLayoutSize(accumulatedOffset));
            if (result.addNodeToListBasedTestResult(lineLayoutItem.node(),
                                                    locationInContainer,
                                                    rect) == StopHitTesting)
              return true;
          }
        }
      }
    }
  }
  return false;
}
Ejemplo n.º 4
0
	void layout() {
		rectCount = 0;
		minimum = 0;
		if (list.isEmpty())
			return;
		_Expand(rects, list.size()+4, 2.1);

		int fills = 0;
		qreal filled = 0;
		auto calculate = [&filled, &fills, this] (const ItemListAttached *attached) {
			filled += 2*O::padding(p, attached);
			if (attached->thickness() < 0) {
				if (length < 0)
					++fills;
				else
					filled += length;
			} else
				filled += attached->thickness();
		};
		runLayoutLoop(calculate);
		const auto fill = qMax((O::length(p) - filled)/fills, 0.0);
		auto it = rects.begin();
		qreal pos = 0;
		auto append = [&it, &pos, fill, this] (ItemListAttached *attached) {
			qreal total = 2*O::padding(p, attached);
			if (attached->thickness() < 0) {
				if (length < 0)
					total += fill;
				else
					total += length;
			} else
				total += attached->thickness();
			attached->fill(total);
			if (attached->isQmlItem()) {
				const auto vpad = pick(attached->verticalPadding(), this->vpad);
				const auto hpad = pick(attached->horizontalPadding(), this->hpad);
				const auto rect = O::itemRect(p, attached, pos, {hpad, vpad});
				auto qml = static_cast<QQuickItem*>(attached->attachee());
				qml->setPosition(rect.topLeft());
				qml->setSize(rect.size());
			}
			it->attached = attached;
			it->pos = pos;
			++it;
			pos += total;
		};
		runLayoutLoop(append);
		rectCount = std::distance(rects.begin(), it);
		if (_Change(minimum, filled))
			emit p->minimumLengthChanged();
		p->setGeometryDirty();
	}
Ejemplo n.º 5
0
void MeaCircleTool::Update(MeaUpdateReason reason)
{
    if (IsEnabled()) {
        MeaTool::Update(reason);

        MeaUnitsMgr& units = MeaUnitsMgr::Instance();
        
        // Convert the pixel locations to the current
        // units.
        //
        FPOINT p1 = units.ConvertCoord(m_center);
        FPOINT p2 = units.ConvertCoord(m_perimeter);

        // Calculate the bounding square around the circle.
        //
        int radius = m_circle.GetRadius();
        CPoint topLeft(m_center.x - radius, m_center.y - radius);
        CPoint bottomRight(m_center.x + radius, m_center.y + radius);
        FSIZE wh = units.GetWidthHeight(topLeft, bottomRight);

        // For the Circle tool the distance value is the
        // length of the radius.
        //
        double r = wh.cx / 2.0;

        // Display the results of the measurement in
        // the data display fields.
        //
        m_mgr->ShowXYV(m_center, p1);
        m_mgr->ShowXY1(m_perimeter, p2);
        m_mgr->ShowWH(wh);
        m_mgr->ShowDistance(r);
        m_mgr->ShowAngle(MeaLayout::GetAngle(p1, p2));
        m_mgr->ShowCircleArea(r);

        // The screen information depends on the
        // current position.
        //
        m_mgr->UpdateScreenInfo(*m_curPos);

        // Display the results of the measurement in
        // the crosshair data windows.
        //
        m_dataWinCenter.ShowXY(p1);
        m_dataWinCenter.ShowDistance(r);
        m_dataWinCenter.Update(m_centerCH);

        m_dataWinPerimeter.ShowXY(p2);
        m_dataWinPerimeter.ShowDistance(r);
        m_dataWinPerimeter.Update(m_perimeterCH);
    }
}
Ejemplo n.º 6
0
int
NBHeightMapper::loadTiff(const std::string& file) {
#ifdef HAVE_GDAL
    GDALAllRegister();
    GDALDataset* poDataset = (GDALDataset*)GDALOpen(file.c_str(), GA_ReadOnly);
    if (poDataset == 0) {
        WRITE_ERROR("Cannot load GeoTIFF file.");
        return 0;
    }
    const int xSize = poDataset->GetRasterXSize();
    const int ySize = poDataset->GetRasterYSize();
    double adfGeoTransform[6];
    if (poDataset->GetGeoTransform(adfGeoTransform) == CE_None) {
        Position topLeft(adfGeoTransform[0], adfGeoTransform[3]);
        mySizeOfPixel.set(adfGeoTransform[1], adfGeoTransform[5]);
        const double horizontalSize = xSize * mySizeOfPixel.x();
        const double verticalSize = ySize * mySizeOfPixel.y();
        myBoundary.add(topLeft);
        myBoundary.add(topLeft.x() + horizontalSize, topLeft.y() + verticalSize);
    } else {
        WRITE_ERROR("Could not parse geo information from " + file + ".");
        return 0;
    }
    const int picSize = xSize * ySize;
    myRaster = (int16_t*)CPLMalloc(sizeof(int16_t) * picSize);
    for (int i = 1; i <= poDataset->GetRasterCount(); i++) {
        GDALRasterBand* poBand = poDataset->GetRasterBand(i);
        if (poBand->GetColorInterpretation() != GCI_GrayIndex) {
            WRITE_ERROR("Unknown color band in " + file + ".");
            clearData();
            break;
        }
        if (poBand->GetRasterDataType() != GDT_Int16) {
            WRITE_ERROR("Unknown data type in " + file + ".");
            clearData();
            break;
        }
        assert(xSize == poBand->GetXSize() && ySize == poBand->GetYSize());
        if (poBand->RasterIO(GF_Read, 0, 0, xSize, ySize, myRaster, xSize, ySize, GDT_Int16, 0, 0) == CE_Failure) {
            WRITE_ERROR("Failure in reading " + file + ".");
            clearData();
            break;
        }
    }
    GDALClose(poDataset);
    return picSize;
#else
    UNUSED_PARAMETER(file);
    WRITE_ERROR("Cannot load GeoTIFF file since SUMO was compiled without GDAL support.");
    return 0;
#endif
}
Ejemplo n.º 7
0
Rectangle::operator Json() const
{
    Json j;
    cv::Point2f topleft = topLeft();
    j[top_left_x_Key] = topleft.x;
    j[top_left_y_Key] = topleft.y;

    cv::Point2f bottomRight = topRight();
    j[bottom_right_x_Key] = bottomRight.x;
    j[bottom_right_y_Key] = bottomRight.y;

    return j;
}
Ejemplo n.º 8
0
void CHlpView::SizeChanged()
	{
	const TInt KKludgeFactor = 4;

	TRect rect(Position(), Rect().Size());
	TSize choiceListSize = iHelpCategories->MinimumSize() + TSize(0, KKludgeFactor);

	TPoint topLeft(rect.iTl);

	iHelpCategories->SetExtent(topLeft, TSize(rect.Width()/2, choiceListSize.iHeight));
	iHelpTopicsForCategory->SetExtent(TPoint(rect.Size().iWidth/2,topLeft.iY), TSize(rect.Size().iWidth/2, choiceListSize.iHeight));
	iRichTextEditor->SetRect(TRect(TPoint(topLeft.iX, choiceListSize.iHeight), rect.iBr));
	}
Ejemplo n.º 9
0
void SimpleGraphicsView::setCurrentLabelPositionFromTextField(ivec2 pos) {
    if (currentRectItem_) {
        SimpleWithRectangleLabel* rectItem = qgraphicsitem_cast<SimpleWithRectangleLabel*>(currentRectItem_);

        if (rectItem) {
            vec2 topLeft(pos.x, pos.y);
            QRectF rect = rectItem->mapRectToScene(rectItem->rect());
            vec2 rectSize(rect.size().width(), rect.size().height());
            topLeft = topLeft - (rectSize/2.0f);
            rectItem->setPos(QPointF(topLeft.x, topLeft.y));
        }
    }
}
Ejemplo n.º 10
0
// Return the largest rectangle that fits in aRect and has the
// same aspect ratio as aRatio, centered at the center of aRect
static gfxRect
CorrectForAspectRatio(const gfxRect& aRect, const nsIntSize& aRatio)
{
  NS_ASSERTION(aRatio.width > 0 && aRatio.height > 0 && !aRect.IsEmpty(),
               "Nothing to draw");
  // Choose scale factor that scales aRatio to just fit into aRect
  gfxFloat scale =
    PR_MIN(aRect.Width()/aRatio.width, aRect.Height()/aRatio.height);
  gfxSize scaledRatio(scale*aRatio.width, scale*aRatio.height);
  gfxPoint topLeft((aRect.Width() - scaledRatio.width)/2,
                   (aRect.Height() - scaledRatio.height)/2);
  return gfxRect(aRect.TopLeft() + topLeft, scaledRatio);
}
Ejemplo n.º 11
0
void BitmapImage::drawEllipse( QRectF rectangle, QPen pen, QBrush brush, QPainter::CompositionMode cm, bool antialiasing)
{
    int width = pen.width();
    extend( rectangle.adjusted(-width,-width,width,width).toRect() );
    if (brush.style() == Qt::RadialGradientPattern)
    {
        QRadialGradient* gradient = (QRadialGradient*)brush.gradient();
        gradient->setCenter( gradient->center() - topLeft() );
        gradient->setFocalPoint( gradient->focalPoint() - topLeft() );
    }
    if (mImage != NULL && !mImage->isNull() )
    {
        QPainter painter(mImage);
        painter.setCompositionMode(cm);
        painter.setRenderHint(QPainter::Antialiasing, antialiasing);
        painter.setPen(pen);
        painter.setBrush(brush);
        //if (brush == Qt::NoBrush)
        painter.drawEllipse( rectangle.translated(-topLeft()) );
        painter.end();
    }
}
Ejemplo n.º 12
0
void Crop::setup()
{
    rubberBand = new QRubberBand(QRubberBand::Rectangle, this);

    QPoint topLeft(x, y);
    QPoint bottomRight(x + width, y + height);
    image = new QRect(topLeft, bottomRight);

    toDraw = false;
    toClear = false;

    cropping = QRect(0,0,0,0);
}
Ejemplo n.º 13
0
void ImageEditorWidgetQt::loadImageLabel() {
    if (tmpPropertyValue_!=static_cast<FileProperty*>(property_)->get()) {
        tmpPropertyValue_ = static_cast<FileProperty*>(property_)->get();
        imageLabelWidget_->addBackGroundImage(tmpPropertyValue_);
        ImageEditorProperty* imageProperty  = static_cast<ImageEditorProperty*>(property_);
        const std::vector<ImageLabel> labels = imageProperty->getLabels();

        for (auto& label : labels) {
            QPointF topLeft(label.getTopLeft()[0], label.getTopLeft()[1]);
            QPointF rectSize(label.getSize()[0], label.getSize()[1]);
            imageLabelWidget_->view_->addRectangle(topLeft, rectSize);
        }
    }
}
Ejemplo n.º 14
0
void TableSideSelector::paintEvent(QPaintEvent* event)
{
	double edgeWidth = 5;
	double inset = edgeWidth/2 + frameWidth()*2;

	QPointF topLeft(inset, inset);
	QPointF topRight(width() - inset, inset);
	QPointF bottomLeft(inset, height() - inset);
	QPointF bottomRight(width() - inset, height() - inset);

	m_left = QLineF(topLeft, bottomLeft);
	m_right = QLineF(topRight, bottomRight);
	m_top = QLineF(topRight, topLeft);
	m_bottom = QLineF(bottomRight, bottomLeft);

	QPainter painter(this);

	// Paint selection.
	painter.setPen(QPen(Qt::black, edgeWidth, Qt::SolidLine, Qt::RoundCap));
	if (m_selection & Left) painter.drawLine(m_left);
	if (m_selection & Right) painter.drawLine(m_right);
	if (m_selection & Top) painter.drawLine(m_top);
	if (m_selection & Bottom) painter.drawLine(m_bottom);

	// Paint the dotted grid.
	painter.setPen(QPen(Qt::gray, edgeWidth/4, Qt::DotLine));
	painter.drawRect(QRectF(topLeft, bottomRight));
	painter.drawLine(m_left.pointAt(0.5), m_right.pointAt(0.5));
	painter.drawLine(m_top.pointAt(0.5), m_bottom.pointAt(0.5));

	// Paint highlighting.
	painter.setPen(QPen(QColor(255, 255, 255, 60), edgeWidth, Qt::SolidLine, Qt::RoundCap));
	switch (m_highlighted)
	{
	case Left:
		painter.drawLine(m_left);
		break;
	case Right:
		painter.drawLine(m_right);
		break;
	case Top:
		painter.drawLine(m_top);
		break;
	case Bottom:
		painter.drawLine(m_bottom);
		break;
	default:
		break;
	}
}
void tag_recognition::cutWords(cv::Mat wordsMask, cv::Mat rawDst, cv::Mat &word1, cv::Mat &word2)
{
    std::vector < std::vector<cv::Point2f> > rotatedBlobs;
    cv::normalize(wordsMask,wordsMask,0,1,cv::NORM_MINMAX);
    this->findBlobs(wordsMask,rotatedBlobs);
    rotatedBlobs = this->removeImpossibleBlobs(rotatedBlobs);
    //    qDebug() << rotatedBlobs.size();
    if(rotatedBlobs.size() < 2)
    {
        cv::normalize(wordsMask,wordsMask,0,255,cv::NORM_MINMAX);
//        cv::imshow("WTF",wordsMask);
        word1 = cv::Mat::zeros(1,1,CV_8UC1);
        word2 = cv::Mat::zeros(1,1,CV_8UC1);
        return;
    }

    std::vector<cv::Point2f> topLeft(rotatedBlobs.size());
    std::vector<cv::Point2f> downRight(rotatedBlobs.size());

    for(int i = 0; i < rotatedBlobs.size(); i++)
    {
        topLeft[i] = cv::Point2f(tagSize,tagSize);
        downRight[i] = cv::Point2f(0,0);
        for(int j=0; j < rotatedBlobs[i].size(); j++)
        {
            if(topLeft[i].x > rotatedBlobs[i][j].x)
                topLeft[i].x = rotatedBlobs[i][j].x;
            if(topLeft[i].y > rotatedBlobs[i][j].y)
                topLeft[i].y = rotatedBlobs[i][j].y;
            if(downRight[i].x < rotatedBlobs[i][j].x)
                downRight[i].x = rotatedBlobs[i][j].x;
            if(downRight[i].y < rotatedBlobs[i][j].y)
                downRight[i].y = rotatedBlobs[i][j].y;
        }
        //        qDebug() << topLeft.x << topLeft.y << downRight.x << downRight.y;
        //        cv::imshow(std::to_string(i),dst);
    }

    if(topLeft[0].x < topLeft[1].x)
    {
        cv::getRectSubPix(rawDst,cv::Size(downRight[0].x-topLeft[0].x+4,downRight[0].y-topLeft[0].y+4),(downRight[0]+topLeft[0])/2,word1);
        cv::getRectSubPix(rawDst,cv::Size(downRight[1].x-topLeft[1].x+4,downRight[1].y-topLeft[1].y+4),(downRight[1]+topLeft[1])/2,word2);
    }
    else
    {
        cv::getRectSubPix(rawDst,cv::Size(downRight[0].x-topLeft[0].x+4,downRight[0].y-topLeft[0].y+4),(downRight[0]+topLeft[0])/2,word2);
        cv::getRectSubPix(rawDst,cv::Size(downRight[1].x-topLeft[1].x+4,downRight[1].y-topLeft[1].y+4),(downRight[1]+topLeft[1])/2,word1);
    }

}
Ejemplo n.º 16
0
void CProgressBar::drawRects(QPainter *painter)
{
    painter->save();
    painter->setPen(Qt::NoPen);
    painter->setRenderHints(QPainter::Antialiasing);

    qreal initX = PI_EXTRA_SPACE;
    qreal top = PI_EXTRA_SPACE;
    qreal bottom = height() - PI_EXTRA_SPACE;
    qreal rectWidth = (qreal)(width() - PI_RECT_COUNT * PI_EXTRA_SPACE)/PI_RECT_COUNT;

    for(int rectIndex = 0 ; rectIndex <= PI_RECT_COUNT ; rectIndex++)
    {
        QPointF topLeft(initX,top);
        QPointF bottomRight(initX + rectWidth,bottom);
        QRectF theRect(topLeft,bottomRight);

        if(rectIndex <= m_nCurrValue )
        {
            QLinearGradient rectGradient(theRect.topLeft(),theRect.topRight());
            rectGradient.setColorAt(0.0,QColor(85,120,0));
            rectGradient.setColorAt(0.1,QColor(70,150,20));
            rectGradient.setColorAt(0.5,QColor(70,220,20));
            rectGradient.setColorAt(0.9,QColor(70,150,20));
            rectGradient.setColorAt(1.0,QColor(85,120,0));
            painter->setBrush(rectGradient);

            if(rectIndex == m_nCurrValue)
            {
                emit sig_Finished();
            }
        }
		else
		{
            QLinearGradient rectGradient(theRect.topLeft(),theRect.topRight());
            rectGradient.setColorAt(0.0,QColor(120,120,120));
            rectGradient.setColorAt(0.1,QColor(160,160,160));
            rectGradient.setColorAt(0.5,QColor(210,210,210));
            rectGradient.setColorAt(0.9,QColor(160,160,160));
            rectGradient.setColorAt(1.0,QColor(120,120,120));
            painter->setBrush(rectGradient);
        }
        painter->drawRoundedRect(theRect,PI_ANGLE_RADIUS,PI_ANGLE_RADIUS);

        initX +=rectWidth + PI_EXTRA_SPACE;

    }

    painter->restore();
}
Ejemplo n.º 17
0
// 获取矩形范围内,所有四叉树的所有物体
// 如果这个矩形是完全处于一个四叉树中的,那么跟Retrieve返回的结果一样
// 如果这个矩形处于多个四叉树中,那么需要获取它所在的四叉树,以及它四个点所在四叉树的物体
void FixedQuadTree::RetrieveArea(const plane_shooting::Rectangle& rect, list<Object*>& objList) {
	Retrieve(rect, objList);

	// 左上顶点
	Rectangle topLeft(rect.x - rect.fWidth / 2, rect.y + rect.fHeight / 2, 0, 1);
	// 右上顶点
	Rectangle topRight(rect.x + rect.fWidth / 2, rect.y + rect.fHeight / 2, 0, 1);
	// 左下顶点
	Rectangle bottomLeft(rect.x - rect.fWidth / 2, rect.y - rect.fHeight / 2, 0, 1);
	// 右下顶点
	Rectangle bottomRight(rect.x + rect.fWidth / 2, rect.y - rect.fHeight / 2, 0, 1);

	// TODO , 改成直接返回list<Object*>列表指针
}
Ejemplo n.º 18
0
		float FindLaplacianValue(
			const MatrixF& img,
			const Remapping& remapping,
			float gvalue,
			int level,
			int row,
			int col )
		{
			//find the total size we need
			int size = 3 * ( pow(2.0f,level+2) - 1 );
			int halfSize = size / 2;

			//find the corresponding point from that level to original image
			int rowTemp = row*pow(2.0f,level);
			int colTemp = col*pow(2.0f,level);

			//copy the whole block (replicating when necessary)
			MatrixF mat[2];
			MatrixF* dest0 = &(mat[0]);
			MatrixF* dest1 = &(mat[1]);

			Point topLeft( colTemp - halfSize, rowTemp - halfSize );
			Point bottomRight( colTemp + halfSize, rowTemp + halfSize );
			Copy( img, topLeft, bottomRight, *dest0 );
			RemapImage(*dest0, gvalue, remapping, *dest0);

			Pyramid::Gaussian( *dest0, *dest1, 0.4f );
			Copy( *dest1, Point(2,2), Point(dest1->Cols()-3,dest1->Rows()-3), *dest1);
			Decimate(*dest1,*dest1);

			for(int i = 0; i < level; ++i)
			{
				std::swap( dest0, dest1 );
				Pyramid::Gaussian( *dest0, *dest1, 0.4f );
				Copy( *dest1, Point(2,2), Point(dest1->Cols()-3,dest1->Rows()-3), *dest1);
				Decimate(*dest1,*dest1);
			}

			//expand
			assert( dest1->Rows() == 3 );
			assert( dest1->Cols() == 3 );
			ExpandOdd( *dest1, *dest1, 0.4f ); //now 5X5

			//we need to also reduce dest0
			Copy( *dest0, Point(2,2), Point(dest0->Cols()-3,dest0->Rows()-3), *dest0);
			MatrixF laplacian;
			Subtract(*dest0, *dest1, laplacian);
			return laplacian[laplacian.Rows()/2][laplacian.Cols()/2];
		}
void FixedHeightLayoutManager::calculateLineHeight(void)
{
		// calculating the character height using 'A' as the standard character
		heightOfLine = LINEHEIGHT;
		
		UInt32 lineSpacing = getParentTextDomArea()->getLineSpacing();

		Vec2f topLeft(0,0),bottomRight(0,0);

		if(getParentTextDomArea()->getFont())
		{
			getParentTextDomArea()->getFont()->getBounds("A",topLeft,bottomRight);
			heightOfLine = bottomRight.y() - topLeft.y();
		}
}
Ejemplo n.º 20
0
void BlockRemoveButton::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
    painter->setPen(m_Pen);
    painter->setBrush(m_Brush);
    
    QPointF topLeft(0, 0);
    QPointF bottomRight(m_Width, m_Height);
    QRectF rect(topLeft, bottomRight);
    painter->drawEllipse(rect);

    qreal widthPer4 = m_Width / 4.0;
    qreal heightPer4 = m_Height / 4.0;
    painter->drawLine(widthPer4, heightPer4, 3 * widthPer4, 3 * heightPer4);
    painter->drawLine(widthPer4, 3 * heightPer4, 3 * widthPer4, heightPer4);
}
Ejemplo n.º 21
0
// ---------------------------------------------------------------------------
// CEikCapCArray::MoveLineToScreen
// ---------------------------------------------------------------------------
//
void CEikCapCArray::MoveLineToScreen( TInt aLine, TInt aTopY, TBool aVisible )
{
    if ( aLine != -1 && aLine < Count() )
    {
        CEikCaptionedControl* line = (*this)[aLine];
        TPoint topLeft( 1000, 0 );

        if ( aVisible )
        {
            topLeft.SetXY( Rect().iTl.iX, LineIndexToYPosition( aLine, aTopY ) );
        }

        line->SetRect( TRect( topLeft, line->Size() ) );
    }
}
Ejemplo n.º 22
0
// --------------------------------------------------------------------------------------
void DisplayHelpBalloons(WindowRef prefsWindow)
{
	GrafPtr savedPort;
	Point mouseLocation;
	Rect hotRects[3];
	short hotRectID;
	static int previousHotRectID = kNotInHotRect;
	
	GetPort(&savedPort);
	SetPortWindowPort(prefsWindow);
	
	GetMouse(&mouseLocation);
	
	GetWindowProperty(prefsWindow, kAppSignature, kHotRectsTag, 3 * sizeof(Rect), NULL, 
						hotRects);
	
	for (hotRectID = kInList; hotRectID < kNotInHotRect; hotRectID++)
	{
		if (PtInRect(mouseLocation, &hotRects[hotRectID]))
		{
			if (hotRectID != previousHotRectID)
			{
				HMMessageRecord helpMessage;
				Point tips[3];
				
				helpMessage.hmmHelpType = khmmStringRes;
				helpMessage.u.hmmStringRes.hmmResID = rHelpStrings;
				helpMessage.u.hmmStringRes.hmmIndex = hotRectID + 1;
				
				GetWindowProperty(prefsWindow, kAppSignature, kBalloonTipsTag, 
									3 * sizeof(Point), NULL, tips);
				LocalToGlobal(&tips[hotRectID]);
				
				LocalToGlobal(&topLeft(hotRects[hotRectID]));
				LocalToGlobal(&botRight(hotRects[hotRectID]));
				
				HMShowBalloon(&helpMessage, tips[hotRectID], &hotRects[hotRectID], NULL, 
								kBalloonWDEFID, kTopLeftTipPointsLeftVariant, 
								kHMRegularWindow);
			}
				
			break;
		}
	}
	
	previousHotRectID = hotRectID;
	SetPort(savedPort);
}
Ejemplo n.º 23
0
void nsScrollPortView::Scroll(nsView *aScrolledView, nsPoint aTwipsDelta, nsPoint aPixDelta,
                              float aT2P)
{
  if (aTwipsDelta.x != 0 || aTwipsDelta.y != 0)
  {
    nsIWidget *scrollWidget = GetWidget();
    PRBool canBitBlit = scrollWidget && !CannotBitBlt(aScrolledView);

    if (canBitBlit) {
      // We're going to bit-blit.  Let the viewmanager know so it can
      // adjust dirty regions appropriately.
      mViewManager->WillBitBlit(this, aTwipsDelta);
    }
    
    if (!scrollWidget)
    {
      NS_ASSERTION(!canBitBlit, "Someone screwed up");
      nsPoint offsetToWidget;
      GetNearestWidget(&offsetToWidget);
      // We're moving the child widgets because we are scrolling. But
      // the child widgets may stick outside our bounds, so their area
      // may include area that's not supposed to be scrolled. We need
      // to invalidate to ensure that any such area is properly
      // repainted back to the right rendering.
      AdjustChildWidgets(aScrolledView, offsetToWidget, aT2P, PR_TRUE);
      // If we don't have a scroll widget then we must just update.
      // We should call this after fixing up the widget positions to be
      // consistent with the view hierarchy.
      mViewManager->UpdateView(this, 0);
    } else if (!canBitBlit) {
      // We can't blit for some reason.
      // Just update the view and adjust widgets
      // Recall that our widget's origin is at our bounds' top-left
      nsRect bounds(GetBounds());
      nsPoint topLeft(bounds.x, bounds.y);
      AdjustChildWidgets(aScrolledView,
                         GetPosition() - topLeft, aT2P, PR_FALSE);
      // We should call this after fixing up the widget positions to be
      // consistent with the view hierarchy.
      mViewManager->UpdateView(this, 0);
    } else { // if we can blit and have a scrollwidget then scroll.
      // Scroll the contents of the widget by the specfied amount, and scroll
      // the child widgets
      scrollWidget->Scroll(aPixDelta.x, aPixDelta.y, nsnull);
      mViewManager->UpdateViewAfterScroll(this);
    }
  }
}
Ejemplo n.º 24
0
void ofApp::setupScene(int width, int height)
{
    /* setup camera */
    double aspectRatio = static_cast<double>(width) / height;
    ofVec3f topLeft (-CAMERA_SIZE * aspectRatio,  CAMERA_SIZE, 0.0);
    ofVec3f botLeft (-CAMERA_SIZE * aspectRatio, -CAMERA_SIZE, 0.0);
    ofVec3f botRight( CAMERA_SIZE * aspectRatio, -CAMERA_SIZE, 0.0);
    cam = OffAxisCamera(topLeft, botLeft, botRight);
    cam.setPosition(ofVec3f(0.0, 0.0, 50.0f));

    /* calculate grid box dimension */
    ofVec3f camWidthVec = botRight - botLeft;
    double camWidth = camWidthVec.length();
    gridBox = GridBox(ofVec3f(-CAMERA_SIZE * aspectRatio, -CAMERA_SIZE, 0.0f),
            camWidth, camWidth / aspectRatio, 8.0f);
}
Ejemplo n.º 25
0
void BitmapImage::drawEllipse( QRectF rectangle, QPen pen, QBrush brush, QPainter::CompositionMode cm, bool antialiasing)
{
    int width = pen.width();
    extend( rectangle.adjusted(-width,-width,width,width).toRect() );
    if (image != NULL && !image->isNull() )
    {
        QPainter painter(image);
        painter.setCompositionMode(cm);
        painter.setRenderHint(QPainter::Antialiasing, antialiasing);
        painter.setPen(pen);
        painter.setBrush(brush);
        //if (brush == Qt::NoBrush)
        painter.drawEllipse( rectangle.translated(-topLeft()) );
        painter.end();
    }
}
Ejemplo n.º 26
0
Prism::DebugFont::CharacterData Prism::DebugFont::GetCharData(char aChar)
{
	int x = aChar % 16;
	int y = aChar / 16;

	
	CU::Vector2<float> topLeft(x * myCharSize.x, y * myCharSize.y);
	CU::Vector2<float> bottomLeft(topLeft.x + myCharSize.x, topLeft.y + myCharSize.y);


	CharacterData data;
	data.myTopLeftUV = topLeft / 512.f;
	data.myBottomRightUV = bottomLeft / 512.f;

	return data;
}
Ejemplo n.º 27
0
void CIndicator::drawLCDNums(QPainter* painter)
{
    painter->save();

    int topLeftX=boundingRect().width()/10;
    int topLeftY=boundingRect().height()-m_topSpace-m_lcdHeight;
    QPointF topLeft(topLeftX,topLeftY);

    for(int i=0;i<INDICATOR_COUNT;i++)
    {
        lcd[i]->resize(m_lcdWidth,m_lcdHeight);
        lcd[i]->moveBy(topLeftX,topLeftY);
        topLeftX+=m_lcdWidth;
    }
    painter->restore();
}
Ejemplo n.º 28
0
void TalkablePainter::computeIconRect()
{
    QPoint topLeft(CheckboxRect.x() + CheckboxRect.width(), ItemRect.y());
    IconRect = QRect(topLeft, QSize(0, 0));

    const QPixmap &paintedIcon = icon();
    if (paintedIcon.isNull())
        return;

    IconRect.setSize(paintedIcon.size() + QSize(HFrameMargin, 0));

    if (!Configuration->alignTop())
        IconRect.moveTop(ItemRect.top() + (ItemRect.height() - paintedIcon.height()) / 2);
    else if (fontMetrics().lineSpacing() > paintedIcon.height())
        IconRect.moveTop(ItemRect.top() + (fontMetrics().lineSpacing() - paintedIcon.height()) / 2);
}
Ejemplo n.º 29
0
void ScriptEditorCloseButton::paint(QPainter* p,
                                    const QStyleOptionGraphicsItem* o,
                                    QWidget* w)
{
    Q_UNUSED(o);
    Q_UNUSED(w);

    auto br = boundingRect();
    p->setPen(QPen(Colors::base06, 3));

    int offset = 6;
    p->drawLine(br.bottomLeft() + QPointF(offset, -offset),
                br.topRight() - QPointF(offset, -offset));
    p->drawLine(br.topLeft() + QPointF(offset, offset),
                br.bottomRight() - QPointF(offset, offset));
}
Ejemplo n.º 30
0
QPoint HintsWidgetPositioner::positionForSize(QSize size)
{
	auto availableGeometry = QApplication::desktop()->availableGeometry(m_hintsWidget);
	switch (m_hintsConfiguration->corner())
	{
		case HintsConfiguration::Corner::TopLeft:
			return availableGeometry.topLeft() + QPoint{8, 8};
		case HintsConfiguration::Corner::TopRight:
			return availableGeometry.topRight() + QPoint{-8 - size.width(), 8};
		case HintsConfiguration::Corner::BottomLeft:
			return availableGeometry.bottomLeft() + QPoint{8, -8 - size.height()};
		case HintsConfiguration::Corner::BottomRight:
		default:
			return availableGeometry.bottomRight() + QPoint{-8 - size.width(), -8 - size.height()};
	}
}