コード例 #1
0
/*
RectanglesDrawEventHandler : Handles the draw events for the "Rectangles" window.

Parameter DescriptionsinHandler : A reference to the current handler call chain. This is passed to your handler so that you can call CallNextEventHandler if you need to.
inEvent : The event that triggered this call.
inUserData : The application-specific data you passed in to InstallEventHandler.
*/
OSStatus RectanglesDrawEventHandler (EventHandlerCallRef inHandler, EventRef inEvent, void* inUserData) {
	OSStatus status = eventNotHandledErr;
	CGContextRef context;
    CGRect r;
	
	//CallNextEventHandler in order to make sure the default handling of the inEvent 
	// (drawing the white background) happens
	status = CallNextEventHandler( inHandler, inEvent );
	require_noerr(status, CantCallNextEventHandler);
	
	// Get the CGContextRef
	status = GetEventParameter (inEvent, 
								kEventParamCGContextRef, 
								typeCGContextRef, 
								NULL, 
								sizeof (CGContextRef),
								NULL,
								&context);
	require_noerr(status, CantGetEventParameter);
	
	/* Set the stroke color to black. */
    CGContextSetRGBStrokeColor(context, 0, 0, 0, 1);
	
    r.size.height = 210;
    r.origin.x = 20;
    r.origin.y = 20;
    r.size.width = 210;
    frameRect(context, r);
	
    r.size.height = 145;
    r.origin.x = 75;
    r.origin.y = 55;
    r.size.width = 100;
    frameRect(context, r);

    /* Set the fill color to green. */
    CGContextSetRGBFillColor(context, 0, 1, 0, 1);
	
    r.size.height = 210;
    r.origin.x = 270;
    r.origin.y = 20;
    r.size.width = 210;
    paintRect(context, r);
	
    /* Set the fill color to yellow. */
    CGContextSetRGBFillColor(context, 1, 1, 0, 1);
	
    r.size.height = 145;
    r.origin.x = 325;
    r.origin.y = 55;
    r.size.width = 100;
    paintRect(context, r);
	
CantCallNextEventHandler:
CantGetEventParameter:
		
		return status;
}
コード例 #2
0
void CCoordinateLineDisplay::Draw(const TRect& aRect) const
{
   TValueParts parts;
   SetCoordinate(iVal, parts);
   const TInt numLetters = sizeof("E 179+59+59+99+") - 1;
   const TInt pixelwidth = Rect().Width() - 16;
   const TInt step = pixelwidth / numLetters;

   CWindowGc& gc = SystemGc();
   gc.SetClippingRect(aRect);
   gc.SetBrushColor(iBgClr);
   gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
   //gc.Clear(Rect()); //paint background color.
   gc.SetPenStyle(CGraphicsContext::ESolidPen);
   gc.SetPenColor(iTxtClr);   

#if defined NAV2_CLIENT_SERIES80 || defined NAV2_CLIENT_SERIES90_V1
   TCknLogicalFont logicalfont(TCknLogicalFont::EViewLevel2ZoomDefaultFont);
   const class CFont* font = iEikonEnv->Font(logicalfont);
#else
   const class CFont* font = CCoeEnv::Static()->NormalFont();
#endif
   gc.UseFont(font);
   
   TPoint offset(Rect().iTl.iX + (step/2), Rect().iTl.iY + 2);
   TInt baseline = font->AscentInPixels();

   TRect paintRect(offset, TSize(step, Rect().Height() - 4));
   baseline = baseline + ((paintRect.Height() - baseline)/2) - 1;
   for(TInt pos = 0; pos < iNewString.Length(); ++pos){
      gc.DrawText(iNewString.Mid(pos,1), paintRect, baseline, CGraphicsContext::ECenter);
      paintRect.Move(step, 0);
   }
}
コード例 #3
0
ファイル: kled.cpp プロジェクト: ViktorNova/chipsynth
void KLed::paintEvent( QPaintEvent* )
{
    switch( d->shape ) {
      case Rectangular:
        switch ( d->look ) {
          case Sunken:
            paintRectFrame( false );
            break;
          case Raised:
            paintRectFrame( true );
            break;
          case Flat:
            paintRect();
            break;
        }
        break;
      case Circular:
        switch ( d->look ) {
          case Flat:
            paintFlat();
            break;
          case Raised:
            paintRaised();
            break;
          case Sunken:
            paintSunken();
            break;
        }
        break;
    }
}
コード例 #4
0
void FolderThumbnailGenerator::_paintThumbnailsMosaic(
    QImage& img, const QFileInfoList& fileList) const
{
    const int numPreviews =
        std::min(FOLDER_THUMBNAILS_X * FOLDER_THUMBNAILS_Y, fileList.size());
    if (numPreviews == 0)
        return;

    QVector<QRectF> rect =
        _calculatePlacement(FOLDER_THUMBNAILS_X, FOLDER_THUMBNAILS_Y,
                            FOLDER_THUMBNAILS_PADDING, img.size().width(),
                            img.size().height());
    QPainter painter(&img);
    for (int i = 0; i < numPreviews; ++i)
    {
        const auto filename = fileList.at(i).absoluteFilePath();

        QImage thumbnail;
        // Avoid recursion into subfolders
        if (QDir(filename).exists())
            thumbnail = _createFolderImage(QDir(filename), false);
        else
            thumbnail = thumbnail::create(filename, rect[i].size().toSize());

        // Draw the thumbnail centered in its rectangle, preserving aspect ratio
        QSizeF paintedSize(thumbnail.size());
        paintedSize.scale(rect[i].size(), Qt::KeepAspectRatio);
        QRectF paintRect(QPointF(), paintedSize);
        paintRect.moveCenter(rect[i].center());
        painter.drawImage(paintRect, thumbnail);
    }
    painter.end();
}
コード例 #5
0
ファイル: Painter.cpp プロジェクト: Mandarancio/Vector
void Painter::paintRect(Sint16 x, Sint16 y, Uint16 w, Uint16 h) {
	SDL_Rect r;
	r.x = x;
	r.y = y;
	r.w = w;
	r.h = h;

	paintRect(r);
}
コード例 #6
0
ファイル: SVGFEImage.cpp プロジェクト: sysrqb/chromium-src
void FEImage::determineAbsolutePaintRect()
{
    ASSERT(m_image);
    FloatRect srcRect(FloatPoint(), m_image->size());
    FloatRect paintRect(m_absoluteSubregion);
    m_preserveAspectRatio.transformRect(paintRect, srcRect);
    paintRect.intersect(maxEffectRect());
    setAbsolutePaintRect(enclosingIntRect(paintRect));
}
コード例 #7
0
ファイル: paint16.cpp プロジェクト: pdpdds/scummvm
void GfxPaint16::frameRect(const Common::Rect &rect) {
	Common::Rect r = rect;
	// left
	r.right = rect.left + 1;
	paintRect(r);
	// right
	r.right = rect.right;
	r.left = rect.right - 1;
	paintRect(r);
	//top
	r.left = rect.left;
	r.bottom = rect.top + 1;
	paintRect(r);
	//bottom
	r.bottom = rect.bottom;
	r.top = rect.bottom - 1;
	paintRect(r);
}
コード例 #8
0
ファイル: FieldsetPainter.cpp プロジェクト: kjthegod/WebKit
void FieldsetPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
    if (!paintInfo.shouldPaintWithinRoot(&m_renderFieldset))
        return;

    LayoutRect paintRect(paintOffset, m_renderFieldset.size());
    RenderBox* legend = m_renderFieldset.findLegend();
    if (!legend)
        return BoxPainter(m_renderFieldset).paintBoxDecorationBackground(paintInfo, paintOffset);

    // FIXME: We need to work with "rl" and "bt" block flow directions.  In those
    // cases the legend is embedded in the right and bottom borders respectively.
    // https://bugs.webkit.org/show_bug.cgi?id=47236
    if (m_renderFieldset.style()->isHorizontalWritingMode()) {
        LayoutUnit yOff = (legend->location().y() > 0) ? LayoutUnit() : (legend->size().height() - m_renderFieldset.borderTop()) / 2;
        paintRect.setHeight(paintRect.height() - yOff);
        paintRect.setY(paintRect.y() + yOff);
    } else {
        LayoutUnit xOff = (legend->location().x() > 0) ? LayoutUnit() : (legend->size().width() - m_renderFieldset.borderLeft()) / 2;
        paintRect.setWidth(paintRect.width() - xOff);
        paintRect.setX(paintRect.x() + xOff);
    }

    RenderDrawingRecorder recorder(paintInfo.context, m_renderFieldset, paintInfo.phase, pixelSnappedIntRect(paintOffset, paintRect.size()));
    if (recorder.canUseCachedDrawing())
        return;

    BoxDecorationData boxDecorationData(m_renderFieldset, paintInfo.context);

    if (boxDecorationData.bleedAvoidance() == BackgroundBleedNone)
        BoxPainter::paintBoxShadow(paintInfo, paintRect, m_renderFieldset.style(), Normal);
    BoxPainter(m_renderFieldset).paintFillLayers(paintInfo, boxDecorationData.backgroundColor, m_renderFieldset.style()->backgroundLayers(), paintRect);
    BoxPainter::paintBoxShadow(paintInfo, paintRect, m_renderFieldset.style(), Inset);

    if (!boxDecorationData.hasBorder)
        return;

    // Create a clipping region around the legend and paint the border as normal
    GraphicsContext* graphicsContext = paintInfo.context;
    GraphicsContextStateSaver stateSaver(*graphicsContext);

    // FIXME: We need to work with "rl" and "bt" block flow directions.  In those
    // cases the legend is embedded in the right and bottom borders respectively.
    // https://bugs.webkit.org/show_bug.cgi?id=47236
    if (m_renderFieldset.style()->isHorizontalWritingMode()) {
        LayoutUnit clipTop = paintRect.y();
        LayoutUnit clipHeight = max(static_cast<LayoutUnit>(m_renderFieldset.style()->borderTopWidth()), legend->size().height() - ((legend->size().height() - m_renderFieldset.borderTop()) / 2));
        graphicsContext->clipOut(pixelSnappedIntRect(paintRect.x() + legend->location().x(), clipTop, legend->size().width(), clipHeight));
    } else {
        LayoutUnit clipLeft = paintRect.x();
        LayoutUnit clipWidth = max(static_cast<LayoutUnit>(m_renderFieldset.style()->borderLeftWidth()), legend->size().width());
        graphicsContext->clipOut(pixelSnappedIntRect(clipLeft, paintRect.y() + legend->location().y(), clipWidth, legend->size().height()));
    }

    BoxPainter::paintBorder(m_renderFieldset, paintInfo, paintRect, m_renderFieldset.style());
}
コード例 #9
0
ファイル: ImageBox.cpp プロジェクト: aszlig/wx-Youtube
wxRect wxImageBox::getPaintRect()
{
  wxSize size = GetClientSize();
  wxRect paintRect(0, 0, size.GetWidth(), size.GetHeight());
  GetViewStart(&paintRect.x, &paintRect.y);
  int xu,yu;
  GetScrollPixelsPerUnit(&xu, &yu);
  paintRect.x *= xu; paintRect.y *= yu;
  return paintRect;
}
コード例 #10
0
ファイル: painter.c プロジェクト: imre-kerr/tdt4258
/* Make screen go black */
void blankScreen() {
	int i;
	uint16_t *tempfbmap = fbMap;
	printf("Blank screen\n");
	for (i = 0; i < SCREENW*SCREENH; i++) { // Blank screen
		*tempfbmap = BL;
		tempfbmap++;
	}
	paintRect(0, 0, SCREENW, SCREENH);
}
コード例 #11
0
ファイル: GraphicsMovieItem.cpp プロジェクト: Giladx/vlmc
void
GraphicsMovieItem::paint( QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* )
{
    painter->save();
    paintRect( painter, option );
    painter->restore();

    painter->save();
    paintTitle( painter, option );
    painter->restore();
}
コード例 #12
0
void drawWindow( HWND window )
{
	PAINTSTRUCT paintInfo;
	HDC dc = BeginPaint( window, &paintInfo );

	RECT rect;
	GetClientRect( window, &rect );

	paintRect( dc, 0, 87, rect.right, 1, hbSeparator );

	EndPaint( window, &paintInfo );
}
コード例 #13
0
void ScrollbarThemeGtk::paintTrackBackground(GraphicsContext* context, ScrollbarThemeClient* scrollbar, const IntRect& rect)
{
    // Paint the track background. If the trough-under-steppers property is true, this
    // should be the full size of the scrollbar, but if is false, it should only be the
    // track rect.
    IntRect fullScrollbarRect(rect);
    if (m_troughUnderSteppers)
        fullScrollbarRect = IntRect(scrollbar->x(), scrollbar->y(), scrollbar->width(), scrollbar->height());

    WidgetRenderingContext widgetContext(context, fullScrollbarRect);
    IntRect paintRect(IntPoint(), fullScrollbarRect.size());
    widgetContext.gtkPaintBox(paintRect, getWidgetForScrollbar(scrollbar),
                              GTK_STATE_ACTIVE, GTK_SHADOW_IN, "trough");
}
コード例 #14
0
void MediaStreamTrackPrivate::paintCurrentFrameInContext(GraphicsContext& context, const FloatRect& rect)
{
    if (context.paintingDisabled() || m_source->type() != RealtimeMediaSource::Type::Video || ended())
        return;

    if (!m_source->muted())
        m_source->paintCurrentFrameInContext(context, rect);
    else {
        GraphicsContextStateSaver stateSaver(context);
        context.translate(rect.x(), rect.y() + rect.height());
        IntRect paintRect(IntPoint(0, 0), IntSize(rect.width(), rect.height()));
        context.fillRect(paintRect, Color::black);
    }
}
コード例 #15
0
void KLed::paintEvent( QPaintEvent* )
{
#ifdef PAINT_BENCH
  const int rounds = 1000;
  QTime t;
  t.start();
  for ( int i = 0; i < rounds; i++ ) {
#endif
    switch( d->shape ) {
      case Rectangular:
        switch ( d->look ) {
          case Sunken:
            paintRectFrame( false );
            break;
          case Raised:
            paintRectFrame( true );
            break;
          case Flat:
            paintRect();
            break;
          default:
            qWarning( "%s: in class KLed: no KLed::Look set", qApp->argv()[0] );
        }
        break;
      case Circular:
        switch ( d->look ) {
          case Flat:
            paintFlat();
            break;
          case Raised:
            paintRaised();
            break;
          case Sunken:
            paintSunken();
            break;
          default:
            qWarning( "%s: in class KLed: no KLed::Look set", qApp->argv()[0] );
        }
        break;
      default:
        qWarning( "%s: in class KLed: no KLed::Shape set", qApp->argv()[0] );
        break;
    }
#ifdef PAINT_BENCH
  }

  int ready = t.elapsed();
  qWarning( "elapsed: %d msec. for %d rounds", ready, rounds );
#endif
}
コード例 #16
0
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option , QWidget *widget)
    {
        Q_UNUSED(option);
        Q_UNUSED(widget);
        QRectF paintRect(style()->marginLeft(),
                         style()->marginTop(),
                         size().width() - style()->marginLeft() - style()->marginRight(),
                         size().height() - style()->marginTop() - style()->marginBottom());

        painter->fillRect(paintRect, m_color);
        if (isChecked()) {
            painter->setPen(QColor(0, 0, 0));
            painter->drawRect(rect());
        }
    }
コード例 #17
0
void MediaStreamPrivate::paintCurrentFrameInContext(GraphicsContext& context, const FloatRect& rect)
{
    if (context.paintingDisabled())
        return;

    if (active() && m_activeVideoTrack)
        m_activeVideoTrack->paintCurrentFrameInContext(context, rect);
    else {
        GraphicsContextStateSaver stateSaver(context);
        context.translate(rect.x(), rect.y() + rect.height());
        context.scale(FloatSize(1, -1));
        IntRect paintRect(IntPoint(0, 0), IntSize(rect.width(), rect.height()));
        context.fillRect(paintRect, Color::black);
    }
}
コード例 #18
0
ファイル: DesktopWindow.cpp プロジェクト: sim0629/tightvnc
void DesktopWindow::onPaint(DeviceContext *dc, PAINTSTRUCT *paintStruct)
{
  AutoLock al(&m_bufferLock);
  Rect paintRect(&paintStruct->rcPaint);

  if (paintRect.area() != 0) {
    try {
      m_framebuffer.setTargetDC(paintStruct->hdc);
      if (!m_clientArea.isEmpty()) {
        doDraw(dc);
      }
    } catch (Exception &ex) {
      m_logWriter->error(_T("Error in onPaint: %s"), ex.getMessage());
    }
  }
}
コード例 #19
0
ファイル: painter.c プロジェクト: imre-kerr/tdt4258
/* Paint a sprite on screen */
void paintSprite(struct sprite *s) {
	uint16_t *tempfbmap = fbMap;
	tempfbmap += SCREENW * s->y + s->x;
	uint16_t *spriteP = s->a;
	int j;
	int i;
	for (j = 0; j < s->h; j++) {
		for (i = 0; i < s->w; i++) {
			*tempfbmap = *spriteP;
			tempfbmap++;
			spriteP++;
		}
		tempfbmap += SCREENW - s->w;
	}
	/* Pad with sprites speed to ensure updating the region the sprite came from */
	paintRect(s->x - s->speed, s->y - s->speed, s->w + s->speed * 2, s->h+1 + s->speed * 2);
}
コード例 #20
0
void HTMLDelegate::paint(QPainter* painter, const QStyleOptionViewItem & option, const QModelIndex &index) const
{
	paintRect(painter, option, index);
	QStyleOptionViewItemV4 options = option;
	initStyleOption(&options, index);
	painter->save();
	QTextDocument doc;
	doc.setHtml(options.text);
	doc.setTextWidth(options.rect.width());
	doc.setDefaultFont(options.font);
	options.text.clear();
	options.widget->style()->drawControl(QStyle::CE_ItemViewItem, &options, painter);
	painter->translate(options.rect.left(), options.rect.top());
	QRect clip(0, 0, options.rect.width(), options.rect.height());
	doc.drawContents(painter, clip);
	painter->restore();
}
コード例 #21
0
void EllipsisBoxPainter::paintEllipsis(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom, const ComputedStyle& style)
{
    bool haveSelection = !paintInfo.isPrinting() && paintInfo.phase != PaintPhaseTextClip && m_ellipsisBox.getSelectionState() != SelectionNone;

    LayoutRect paintRect(m_ellipsisBox.logicalFrameRect());
    if (haveSelection)
        paintRect.unite(LayoutRect(m_ellipsisBox.selectionRect()));
    m_ellipsisBox.logicalRectToPhysicalRect(paintRect);
    paintRect.moveBy(paintOffset);

    GraphicsContext& context = paintInfo.context;
    DisplayItem::Type displayItemType = DisplayItem::paintPhaseToDrawingType(paintInfo.phase);
    if (DrawingRecorder::useCachedDrawingIfPossible(context, m_ellipsisBox, displayItemType))
        return;

    DrawingRecorder recorder(context, m_ellipsisBox, displayItemType, FloatRect(paintRect));

    LayoutPoint boxOrigin = m_ellipsisBox.locationIncludingFlipping();
    boxOrigin.moveBy(paintOffset);
    LayoutRect boxRect(boxOrigin, LayoutSize(m_ellipsisBox.logicalWidth(), m_ellipsisBox.virtualLogicalHeight()));

    GraphicsContextStateSaver stateSaver(context);
    if (!m_ellipsisBox.isHorizontal())
        context.concatCTM(TextPainter::rotation(boxRect, TextPainter::Clockwise));

    const Font& font = style.font();

    if (haveSelection)
        paintSelection(context, boxOrigin, style, font);
    else if (paintInfo.phase == PaintPhaseSelection)
        return;

    TextPainter::Style textStyle = TextPainter::textPaintingStyle(m_ellipsisBox.getLineLayoutItem(), style, paintInfo);
    if (haveSelection)
        textStyle = TextPainter::selectionPaintingStyle(m_ellipsisBox.getLineLayoutItem(), true, paintInfo, textStyle);

    TextRun textRun = constructTextRun(font, m_ellipsisBox.ellipsisStr(), style, TextRun::AllowTrailingExpansion);
    LayoutPoint textOrigin(boxOrigin.x(), boxOrigin.y() + font.getFontMetrics().ascent());
    TextPainter textPainter(context, font, textRun, textOrigin, boxRect, m_ellipsisBox.isHorizontal());
    textPainter.paint(0, m_ellipsisBox.ellipsisStr().length(), m_ellipsisBox.ellipsisStr().length(), textStyle);
}
コード例 #22
0
void ScaleBarOverlay::paintContent(QPainter &painter)
{
    double scale;
    {
        QMutexLocker lock(&mMutex);
        scale = mLastValue.toDouble();
    }
    if(mActive)
    {
        painter.setBrush(QColor(0,0,0, 160));
        painter.drawRect(mRect);
    }
    double scaleBarLen = mRect.width();
    double scaleValue = -1;
    if(scale > 0)
    {
        scaleValue = visibleScale(mRect.width() * scale);
        scaleBarLen = scaleValue /scale;
    }
    int barHeight = qMin(20, mRect.height()/2);
    QPointF p1(mRect.left(), mRect.bottom() - barHeight);
    QPointF p2(mRect.left()+scaleBarLen, mRect.bottom() - barHeight);
    painter.setPen(mPen);
    painter.drawLine(p1, p2);
    painter.drawLine(p1 + QPoint(0, barHeight), p1 - QPoint(0, barHeight));
    painter.drawLine(p2 + QPoint(0, barHeight), p2 - QPoint(0, barHeight));
    QRectF paintRect(p1 - QPoint(0,qMin(50, mRect.height()/2)), p2);
    mFont.setPixelSize(paintRect.height()*7/8);
    painter.setFont(mFont);
    QStringList unitNames = QStringList("m") <<  "mm" << "µm" << "nm";
    QString suffix = " "+ unitNames[0];
    for(int i=1; i<unitNames.size();i++)
    {
        if(scaleValue >= 1 || scaleValue < 0)
            break;
        scaleValue *= 1000;
        suffix = " "+unitNames[i];
    }
    painter.drawText(paintRect, Qt::AlignCenter, QString::number(scaleValue) + suffix);
}
コード例 #23
0
bool LayoutReplaced::shouldPaint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) const
{
    if (paintInfo.phase != PaintPhaseForeground && !shouldPaintSelfOutline(paintInfo.phase)
        && paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseMask && paintInfo.phase != PaintPhaseClippingMask)
        return false;

    if (!paintInfo.shouldPaintWithinRoot(this))
        return false;

    // if we're invisible or haven't received a layout yet, then just bail.
    if (style()->visibility() != VISIBLE)
        return false;

    LayoutRect paintRect(visualOverflowRect());
    paintRect.unite(localSelectionRect());
    paintRect.moveBy(paintOffset + location());

    if (!paintInfo.cullRect().intersectsCullRect(paintRect))
        return false;

    return true;
}
コード例 #24
0
ファイル: qheader.cpp プロジェクト: kthxbyte/Qt1.45-Linaro
void QHeader::mouseMoveEvent( QMouseEvent *m )
{
    int s = orient == Horizontal ? m->pos().x() : m->pos().y();
    if ( state == Idle ) {
	bool hit = FALSE;
	int i = 0;
	while ( i <= (int) count() ) {
	    if ( i && pPos(i) - MINSIZE/2 < s && s < pPos(i) + MINSIZE/2 &&
		 data->resize.testBit(i-1) ) {
		hit = TRUE;
		if ( orient == Horizontal )
		    setCursor( *hSplitCur );
		else
		    setCursor( *vSplitCur );
		break;
	    }
	    i++;
	}
	if ( !hit )
	    setCursor( arrowCursor );
    } else {
	switch ( state ) {
	case Idle:
	    debug( "QHeader::mouseMoveEvent() (%s) Idle state",
		   name( "unnamed" ) );
	    break;
	case Pressed:
	case Blocked:
	    if ( QABS( s - clickPos ) > 4 && data->move ) {
		state = Moving;
		moveToIdx = -1;
		if ( orient == Horizontal )
		    setCursor( sizeHorCursor );
		else
		    setCursor( sizeVerCursor );
	    }
	    break;
	case Sliding:
	    handleColumnResize( handleIdx, s, FALSE );
	    break;
	case Moving: {
	    int newPos = findLine( s );
	    if ( newPos != moveToIdx ) {
		if ( moveToIdx == handleIdx || moveToIdx == handleIdx + 1 )
		    repaint( sRect(handleIdx) );
		else
		    unMarkLine( moveToIdx );
		moveToIdx = newPos;
		if ( moveToIdx == handleIdx || moveToIdx == handleIdx + 1 )
		    paintRect( pPos( handleIdx ), pSize( handleIdx ) );
		else
		    markLine( moveToIdx );
	    }
	    break;
	}
	default:
	    warning( "QHeader::mouseMoveEvent: (%s) unknown state",
		     name( "unnamed" ) );
	    break;
	}
    }
}
コード例 #25
0
void CFbAccel::paintLine(int xa, int ya, int xb, int yb, const fb_pixel_t col)
{
#if HAVE_TRIPLEDRAGON
	setColor(col);
	dfbdest->DrawLine(dfbdest, xa, ya, xb, yb);
#elif defined(USE_NEVIS_GXA)
	OpenThreads::ScopedLock<OpenThreads::Mutex> m_lock(mutex);
	/* draw a single vertical line from point xa/ya to xb/yb */
	unsigned int cmd = GXA_CMD_NOT_TEXT | GXA_SRC_BMP_SEL(2) | GXA_DST_BMP_SEL(2) | GXA_PARAM_COUNT(2) | GXA_CMD_NOT_ALPHA;

	setColor(col);
	_write_gxa(gxa_base, GXA_LINE_CONTROL_REG, 0x00000404);	/* X is major axis, skip last pixel */
	_write_gxa(gxa_base, cmd, GXA_POINT(xb, yb));		/* end point */
	_write_gxa(gxa_base, cmd, GXA_POINT(xa, ya));		/* start point */
#else
	int dx = abs (xa - xb);
	int dy = abs (ya - yb);
	if (dy == 0) /* horizontal line */
	{
		/* paintRect actually is 1 pixel short to the right,
		 * but that's bug-compatibility with the GXA code */
		paintRect(xa, ya, xb - xa, 1, col);
		return;
	}
	if (dx == 0) /* vertical line */
	{
		paintRect(xa, ya, 1, yb - ya, col);
		return;
	}
	int x;
	int y;
	int End;
	int step;

	if (dx > dy)
	{
		int p = 2 * dy - dx;
		int twoDy = 2 * dy;
		int twoDyDx = 2 * (dy-dx);

		if (xa > xb)
		{
			x = xb;
			y = yb;
			End = xa;
			step = ya < yb ? -1 : 1;
		}
		else
		{
			x = xa;
			y = ya;
			End = xb;
			step = yb < ya ? -1 : 1;
		}

		paintPixel(x, y, col);

		while (x < End)
		{
			x++;
			if (p < 0)
				p += twoDy;
			else
			{
				y += step;
				p += twoDyDx;
			}
			paintPixel(x, y, col);
		}
	}
	else
	{
		int p = 2 * dx - dy;
		int twoDx = 2 * dx;
		int twoDxDy = 2 * (dx-dy);

		if (ya > yb)
		{
			x = xb;
			y = yb;
			End = ya;
			step = xa < xb ? -1 : 1;
		}
		else
		{
			x = xa;
			y = ya;
			End = yb;
			step = xb < xa ? -1 : 1;
		}

		paintPixel(x, y, col);

		while (y < End)
		{
			y++;
			if (p < 0)
				p += twoDx;
			else
			{
				x += step;
				p += twoDxDy;
			}
			paintPixel(x, y, col);
		}
	}
#endif
}
コード例 #26
0
/* this method overrides the default table drawing method and places grid lines only at certain rows and columns */
void ProfilePrintDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
	paintRect(painter, option, index);
	QStyledItemDelegate::paint(painter, option, index);
}
コード例 #27
0
ファイル: qheader.cpp プロジェクト: kthxbyte/QT2-Linaro
/*!
  \reimp
*/
void QHeader::mouseMoveEvent( QMouseEvent *e )
{
    int section;
    bool hit;

    int c = orient == Horizontal ? e->pos().x() : e->pos().y();
    c += offset();

    switch( state ) {
    case Idle:
	hit = FALSE;
	if ( (section = sectionAt( c )) >= 0 ) {
	    int index = d->s2i[section];
	    if ( (index > 0 && c < d->positions[index] + GRIPMARGIN) ||
		 (c > d->positions[index] + d->sizes[section] - GRIPMARGIN) ) {
		if ( index > 0 && c < d->positions[index]  + GRIPMARGIN )
		    section = d->i2s[--index];
		if ( d->resize.testBit(section) ) {
		    hit = TRUE;
#ifndef QT_NO_CURSOR
		    if ( orient == Horizontal )
			setCursor( splitHCursor );
		    else
			setCursor( splitVCursor );
#endif
		}
	    }
	}
#ifndef QT_NO_CURSOR
	if ( !hit )
	    unsetCursor();
#endif
	break;
    case Blocked:
	break;
    case Pressed:
	if ( QABS( c - clickPos ) > 4 && d->move ) {
	    state = Moving;
	    moveToIdx = -1;
#ifndef QT_NO_CURSOR
	    if ( orient == Horizontal )
		setCursor( sizeHorCursor );
	    else
		setCursor( sizeVerCursor );
#endif
	}
	break;
    case Sliding:
	handleColumnResize( handleIdx, c, FALSE );
	break;
    case Moving: {
	int newPos = findLine( c );
	if ( newPos != moveToIdx ) {
	    if ( moveToIdx == handleIdx || moveToIdx == handleIdx + 1 )
		repaint( sRect(handleIdx) );
	    else
		unMarkLine( moveToIdx );
	    moveToIdx = newPos;
	    if ( moveToIdx == handleIdx || moveToIdx == handleIdx + 1 )
		paintRect( pPos( handleIdx ), pSize( handleIdx ) );
	    else
		markLine( moveToIdx );
	}
	break;
    }
    default:
	qWarning( "QHeader::mouseMoveEvent: (%s) unknown state", name() );
	break;
    }
}
コード例 #28
0
void CPlayerToolBar::OnPaint()
{
  //LONGLONG startTime = AfxGetMyApp()->GetPerfCounter();
  CPaintDC dc(this); // device context for painting
  CRect paintRect(dc.m_ps.rcPaint);
  AppSettings& s = AfxGetAppSettings();

  CRect rcClient;
  GetClientRect(&rcClient);
  CMemoryDC hdc(&dc, rcClient);
  hdc.SetBkMode(TRANSPARENT);

  CRect rc;
  GetWindowRect(&rc);

  if( paintRect == m_btnVolBG->m_rcHitest){
    m_btnVolBG->OnPaint( &hdc, rc);
    m_btnVolTm->OnPaint( &hdc, rc);

    return;
  }

  CRect rcBottomSqu = rcClient;
  rcBottomSqu.top = rcBottomSqu.bottom - 10;

  CRect rcUpperSqu = rcClient;

  CMainFrame* pFrame = ((CMainFrame*)AfxGetMainWnd());

  if (s.skinid == ID_SKIN_FIRST)
    hdc.FillSolidRect(rcUpperSqu, s.GetColorFromTheme(_T("ToolBarBG"), NEWUI_COLOR_TOOLBAR_UPPERBG));
  else
  {

    CBitmap* cbm = CBitmap::FromHandle(pFrame->m_btoolbarbg);
    CDC bmpDc;
    bmpDc.CreateCompatibleDC(&hdc);
    HBITMAP oldhbm = (HBITMAP)bmpDc.SelectObject(cbm);
    BITMAP btmp;
    cbm->GetBitmap(&btmp);
    hdc.StretchBlt(0, 0, rcUpperSqu.Width(), rcUpperSqu.Height(), &bmpDc, 0, 0, btmp.bmWidth, btmp.bmHeight - 2, SRCCOPY);
    bmpDc.SelectObject(oldhbm);
  }
  HFONT holdft = NULL;
  if (m_adctrl.GetVisible())
    holdft = (HFONT)hdc.SelectObject(m_adsft);
  else
    holdft = (HFONT)hdc.SelectObject(m_statft);
  hdc.SetTextColor(s.GetColorFromTheme(_T("ToolBarTimeText"), 0xffffff) );

  UpdateButtonStat();

  int volume = min( m_volctrl.GetPos() , m_volctrl.GetRangeMax() );
  m_btnVolTm->m_rcHitest.MoveToXY(m_btnVolBG->m_rcHitest.left +  ( m_btnVolBG->m_rcHitest.Width() * volume / m_volctrl.GetRangeMax() ) - m_btnVolTm->m_rcHitest.Width()/2
    , m_btnVolBG->m_rcHitest.top + (m_btnVolBG->m_rcHitest.Height() -  m_btnVolTm->m_rcHitest.Height() ) / 2 );
  
  m_btnList.PaintAll(&hdc, rc);

  std::wstring sTimeBtnString = m_adctrl.GetCurAd();

  if (!sTimeBtnString.empty())
  {
    int prom_margin = 8;
    CSize size = dc.GetTextExtent(sTimeBtnString.c_str());

    CSUIButton* cbtn = m_btnList.GetButton(L"SHARE");
    
    if (cbtn && cbtn->m_currenthide)
    {
      cbtn = m_btnList.GetButton(L"LOGO");
      if (cbtn && !cbtn->m_currenthide)
        prom_margin = -10;
    }
    if (cbtn && cbtn->m_currenthide)
      cbtn = NULL;
    
    CRect btnrc(prom_margin, 0, 0, 0);
    if (cbtn)
    {
      btnrc = cbtn->m_rcHitest - rc.TopLeft();
      btnrc.left = btnrc.right + prom_margin;
    }
    
    int width = m_btnList.GetRelativeMinLength(rc, cbtn) - prom_margin;
    if (cbtn)
      width -= cbtn->m_rcHitest.Width();

    if (width < 30)
      width = 0;
   
    if (size.cx > 0)
      btnrc.right = btnrc.left + width;//min(width, size.cx);
    else
      btnrc.right = btnrc.left;
    //btnrc.right -= 5;
    btnrc.top = (rc.Height() - size.cy) / 2;
    btnrc.bottom = btnrc.top + size.cy;
    
    m_adctrl.SetRect(btnrc, &hdc);
    m_adctrl.Paint(&hdc);  
  }
  hdc.SelectObject(holdft);

}
コード例 #29
0
ファイル: qmapviewwidget.cpp プロジェクト: veeman/Sokoslide
void QMapViewWidget::paintEvent(QPaintEvent *event) {
	QPainter painter(this);

	painter.setBrush(QBrush(Qt::white));
	painter.setPen(QPen(Qt::black));
	painter.drawRect(0,0,width()-1, height()-1);

	QRect rect = pBackBuffer.rect();
	rect.moveCenter(QPoint(width()/2-1, height()/2-1));
	painter.drawPixmap(rect.topLeft(), pBackBuffer);

	if (pNewTokenType) {
		QRect paintRect(pNewToken.x()*pRectSize + rect.left(), pNewToken.y()*pRectSize + rect.top(), pRectSize-1, pRectSize-1);

		switch (pNewTokenType) {
				case 'r':
					painter.setRenderHint(QPainter::Antialiasing);
					painter.setBrush(QBrush("#FF0000"));
					paintRect.adjust(1,1,-1,-1);
					painter.drawEllipse(paintRect);
					break;
				case 'g':
					painter.setRenderHint(QPainter::Antialiasing);
					painter.setBrush(QBrush("#00FF00"));
					paintRect.adjust(1,1,-1,-1);
					painter.drawEllipse(paintRect);
					break;
				case 'b':
					painter.setRenderHint(QPainter::Antialiasing);
					painter.setBrush(QBrush("#0000FF"));
					paintRect.adjust(1,1,-1,-1);
					painter.drawEllipse(paintRect);
					break;
				case 'R':
					painter.setBrush(QBrush("#FF0000"));
					painter.drawRect(paintRect);
					break;
				case 'G':
					painter.setBrush(QBrush("#00FF00"));
					painter.drawRect(paintRect);
					break;
				case 'B':
					painter.setBrush(QBrush("#0000FF"));
					painter.drawRect(paintRect);
					break;
				default:
					break;
			}
	}

	if (pSelDir) {
		QPen pen(Qt::black);
		pen.setWidth(3);

		painter.setRenderHint(QPainter::Antialiasing);
		painter.setPen(pen);
		painter.setBrush(QBrush(Qt::black));
		painter.drawLine(pArrow[0], pArrow[1]);
		painter.drawPolygon(&pArrow[1], 3);
	}
}
コード例 #30
0
ファイル: paint16.cpp プロジェクト: Templier/scummvm-test
void GfxPaint16::kernelGraphFillBoxForeground(const Common::Rect &rect) {
	paintRect(rect);
}