Exemple #1
0
bool MacPrinterCanvas::finish() {
#if carbon
	return false;
#else
	endPaint();
	PrClosePage(gPrinterPort);
	if (PrError()  != noErr) {
		return false;
	}
	PrCloseDoc(gPrinterPort);
	if (PrError()  != noErr) {
		return false;
	}
	if ((**prRecHdl).prJob.bJDocLoop == bSpoolLoop) {
		TPrStatus theStatus;
		PrPicFile(prRecHdl, nil, nil, nil, &theStatus);
		if (PrError()  != noErr) {
			return false;
		}
	}
	PrClose();
	if (PrError()  != noErr) {
		return false;
	}
	SetPort(oldPort);
//debugfile("MacPrinter::finish\n");
	return true;
#endif
}
Exemple #2
0
void KisToolLineHelper::end()
{
    if (!m_d->enabled) return;
    KIS_ASSERT_RECOVER_RETURN(isRunning());

    endPaint();
    m_d->linePoints.clear();
}
void ThreadSafeCoordinatedSurface::paintToSurface(const IntRect& rect, CoordinatedSurface::Client* client)
{
    ASSERT(client);

    GraphicsContext* context = beginPaint(rect);
    client->paintToSurfaceContext(context);
    endPaint();
}
void MoveAnimation::animate() {
  const int sleepTime = 15;
  const int n = (int)size();
  beginPaint();
  for(bool cont = true; cont;) {
    for(int i = n; i--;) (*this)[i]->paint();
    endPaint();
    if(sleepTime) Sleep(sleepTime);
    cont = false;
    beginPaint();
    for(int i = 0; i < n; i++) {
      (*this)[i]->unpaint();
      cont |= (*this)[i]->step();
    }
  }
  endPaint();
}
Exemple #5
0
//remaining delete
void runbar(int x,int y,int wid,int hei){
	ACL_Image bar;
	char src[]=".\\image.bmp";
	beginPaint();
	//clearDevice();
	loadImage(src,&bar);
	putImageScale(&bar,x,y,wid,hei);
	endPaint();
}
int Setup()
{
	initConsole();
	puts("�כ�ה�כ�ם¶�");
	int width;
	scanf("%d", &width); 
	initWindow("test", 600, 600, width, width);
	beginPaint();
	line(20, 20, width-20, width-20);
	endPaint();
	
	return 0;
} 
Exemple #7
0
int Setup()
{
	initWindow ("Test", DEFAULT, DEFAULT, 800, 600);
	
	initConsole();
	printf("Hello\n");
	
	beginPaint ();
	
	line(10, 10, 100, 100);
	
	endPaint();
	
	return 0;
}
//-------------------------------------------------------------------------------------------------
Action* FlattenBrush::applyHeightToSelection(float height)
{
	beginPaint();
	for (size_t j = 0; j < land->realVerticesMapSide; ++j)
	{
		for (size_t i = 0; i < land->realVerticesMapSide; ++i)
		{
			if (land->isVertexSelected(j, i))
			{
				flattenVertex(j, i, height);
			}
		}
	}
	return endPaint();
}
void paint() {
  static const int ox = 150;
  static const int oy = 150;

  static const int hl = 46;
  static const int ml = 74;
  static const int sl = 120;

  int i;

  beginPaint();

  clearDevice();

  // circle
  setPenWidth(2);
  setPenColor(BLACK);
  setBrushColor(WHITE);
  ellipse(25, 25, 275, 275);

  // label
  setPenWidth(1);
  setPenColor(BLACK);
  for (i = 0; i < 12; ++i) {
    moveTo(ox + 115 * sin(RAD(180 - i * 30)), oy + 115 * cos(RAD(180 - i * 30)));
    lineTo(ox + 125 * sin(RAD(180 - i * 30)), oy + 125 * cos(RAD(180 - i * 30)));
  }

  // hour
  setPenWidth(8);
  setPenColor(BLACK);
  moveTo(ox, oy);
  lineTo(ox + hl * sin(RAD(180 - h * 30)), oy + hl * cos(RAD(180 - h * 30)));

  // minute
  setPenWidth(4);
  setPenColor(GREEN);
  moveTo(ox, oy);
  lineTo(ox + ml * sin(RAD(180 - m * 6)), oy + ml * cos(RAD(180 - m * 6)));

  // second
  setPenWidth(2);
  setPenColor(RED);
  moveTo(ox, oy);
  lineTo(ox + sl * sin(RAD(180 - s * 6)), oy + sl * cos(RAD(180 - s * 6)));

  endPaint();
}
Exemple #10
0
void MacPrinterCanvas::finish() {
	if (!hdc) {return;}
	endPaint();
	//if (!Escape(hdc, NEWFRAME, 0, NULL, NULL)) {
		//DebugMessage("NEWFRAME failed\n");
	//	abort();
	//}
	//if (!Escape(hdc, ENDDOC, 0, NULL, NULL)) {
		//DebugMessage("ENDDOC failed\n");
	//	abort();
	//}
	EndPage(hdc);
	EndDoc(hdc);
	DeleteDC(hdc);
	hdc = 0;
}
Exemple #11
0
int printCDBar(tankClass tank) {
	int barWidth=tank.width+10;
	int barHeight=10;
	int barRelHeight=10;
	int width;
	int barX,barY;
	int color;
	int delta;
	double percent;
	
	barX=tank.x;
	barY=tank.y+tank.width/2+barRelHeight;
	percent=(double)(MAXCD-tank.fireCD)/MAXCD;
	width=percent*barWidth;
	color=255*percent;
	delta=(128-abs(128-color))/2;
	beginPaint();
	setBrushColor(RGB(255-color+delta,color+delta,0));
	rectangle(barX-barWidth/2,barY-barHeight/2,barX-barWidth/2+width,barY+barHeight/2);
	endPaint();
}
Exemple #12
0
/*!
    Synchronizes the backing store, i.e. dirty areas are repainted and flushed.
*/
void QWidgetBackingStore::sync()
{
    QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData();
    if (discardSyncRequest(tlw, tlwExtra)) {
        // If the top-level is minimized, it's not visible on the screen so we can delay the
        // update until it's shown again. In order to do that we must keep the dirty states.
        // These will be cleared when we receive the first expose after showNormal().
        // However, if the widget is not visible (isVisible() returns false), everything will
        // be invalidated once the widget is shown again, so clear all dirty states.
        if (!tlw->isVisible()) {
            dirty = QRegion();
            for (int i = 0; i < dirtyWidgets.size(); ++i)
                resetWidget(dirtyWidgets.at(i));
            dirtyWidgets.clear();
            fullUpdatePending = false;
        }
        return;
    }

    const bool updatesDisabled = !tlw->updatesEnabled();
    bool repaintAllWidgets = false;

    const bool inTopLevelResize = tlwExtra->inTopLevelResize;
    const QRect tlwRect(tlw->data->crect);
    const QRect surfaceGeometry(windowSurface->geometry());
    if ((fullUpdatePending || inTopLevelResize || surfaceGeometry.size() != tlwRect.size()) && !updatesDisabled) {
        if (hasStaticContents()) {
            // Repaint existing dirty area and newly visible area.
            const QRect clipRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height());
            const QRegion staticRegion(staticContents(0, clipRect));
            QRegion newVisible(0, 0, tlwRect.width(), tlwRect.height());
            newVisible -= staticRegion;
            dirty += newVisible;
            windowSurface->setStaticContents(staticRegion);
        } else {
            // Repaint everything.
            dirty = QRegion(0, 0, tlwRect.width(), tlwRect.height());
            for (int i = 0; i < dirtyWidgets.size(); ++i)
                resetWidget(dirtyWidgets.at(i));
            dirtyWidgets.clear();
            repaintAllWidgets = true;
        }
    }

    if (inTopLevelResize || surfaceGeometry != tlwRect)
        windowSurface->setGeometry(tlwRect);

    if (updatesDisabled)
        return;

    if (hasDirtyFromPreviousSync)
        dirty += dirtyFromPreviousSync;

    // Contains everything that needs repaint.
    QRegion toClean(dirty);

    // Loop through all update() widgets and remove them from the list before they are
    // painted (in case someone calls update() in paintEvent). If the widget is opaque
    // and does not have transparent overlapping siblings, append it to the
    // opaqueNonOverlappedWidgets list and paint it directly without composition.
    QVarLengthArray<QWidget *, 32> opaqueNonOverlappedWidgets;
    for (int i = 0; i < dirtyWidgets.size(); ++i) {
        QWidget *w = dirtyWidgets.at(i);
        QWidgetPrivate *wd = w->d_func();
        if (wd->data.in_destructor)
            continue;

        // Clip with mask() and clipRect().
        wd->dirty &= wd->clipRect();
        wd->clipToEffectiveMask(wd->dirty);

        // Subtract opaque siblings and children.
        bool hasDirtySiblingsAbove = false;
        // We know for sure that the widget isn't overlapped if 'isMoved' is true.
        if (!wd->isMoved)
            wd->subtractOpaqueSiblings(wd->dirty, &hasDirtySiblingsAbove);
        // Scrolled and moved widgets must draw all children.
        if (!wd->isScrolled && !wd->isMoved)
            wd->subtractOpaqueChildren(wd->dirty, w->rect());

        if (wd->dirty.isEmpty()) {
            resetWidget(w);
            continue;
        }

        const QRegion widgetDirty(w != tlw ? wd->dirty.translated(w->mapTo(tlw, QPoint()))
                                           : wd->dirty);
        toClean += widgetDirty;

#ifndef QT_NO_GRAPHICSVIEW
        if (tlw->d_func()->extra->proxyWidget) {
            resetWidget(w);
            continue;
        }
#endif

        if (!hasDirtySiblingsAbove && wd->isOpaque && !dirty.intersects(widgetDirty.boundingRect())) {
            opaqueNonOverlappedWidgets.append(w);
        } else {
            resetWidget(w);
            dirty += widgetDirty;
        }
    }
    dirtyWidgets.clear();

    fullUpdatePending = false;

    if (toClean.isEmpty()) {
        // Nothing to repaint. However, we might have newly exposed areas on the
        // screen if this function was called from sync(QWidget *, QRegion)), so
        // we have to make sure those are flushed.
        flush();
        return;
    }

#ifndef QT_NO_GRAPHICSVIEW
    if (tlw->d_func()->extra->proxyWidget) {
        updateStaticContentsSize();
        dirty = QRegion();
        const QVector<QRect> rects(toClean.rects());
        for (int i = 0; i < rects.size(); ++i)
            tlw->d_func()->extra->proxyWidget->update(rects.at(i));
        return;
    }
#endif

#ifndef Q_BACKINGSTORE_SUBSURFACES
    BeginPaintInfo beginPaintInfo;
    beginPaint(toClean, tlw, windowSurface, &beginPaintInfo);
    if (beginPaintInfo.nothingToPaint) {
        for (int i = 0; i < opaqueNonOverlappedWidgets.size(); ++i)
            resetWidget(opaqueNonOverlappedWidgets[i]);
        dirty = QRegion();
        return;
    }
#endif

    // Must do this before sending any paint events because
    // the size may change in the paint event.
    updateStaticContentsSize();
    const QRegion dirtyCopy(dirty);
    dirty = QRegion();

    // Paint opaque non overlapped widgets.
    for (int i = 0; i < opaqueNonOverlappedWidgets.size(); ++i) {
        QWidget *w = opaqueNonOverlappedWidgets[i];
        QWidgetPrivate *wd = w->d_func();

        int flags = QWidgetPrivate::DrawRecursive;
        // Scrolled and moved widgets must draw all children.
        if (!wd->isScrolled && !wd->isMoved)
            flags |= QWidgetPrivate::DontDrawOpaqueChildren;
        if (w == tlw)
            flags |= QWidgetPrivate::DrawAsRoot;

        QRegion toBePainted(wd->dirty);
        resetWidget(w);

#ifdef Q_BACKINGSTORE_SUBSURFACES
        QWindowSurface *subSurface = w->windowSurface();
        BeginPaintInfo beginPaintInfo;

        QPoint off = w->mapTo(tlw, QPoint());
        toBePainted.translate(off);
        beginPaint(toBePainted, w, subSurface, &beginPaintInfo, true);
        toBePainted.translate(-off);

        if (beginPaintInfo.nothingToPaint)
            continue;

        if (beginPaintInfo.windowSurfaceRecreated) {
            // Eep the window surface has changed. The old one may have been
            // deleted, in which case we will segfault on the call to
            // painterOffset() below. Use the new window surface instead.
            subSurface = w->windowSurface();
        }

        QPoint offset(tlwOffset);
        if (subSurface == windowSurface)
            offset += w->mapTo(tlw, QPoint());
        else
            offset = static_cast<QWSWindowSurface*>(subSurface)->painterOffset();
        wd->drawWidget(subSurface->paintDevice(), toBePainted, offset, flags, 0, this);

        endPaint(toBePainted, subSurface, &beginPaintInfo);
#else
        QPoint offset(tlwOffset);
        if (w != tlw)
            offset += w->mapTo(tlw, QPoint());
        wd->drawWidget(windowSurface->paintDevice(), toBePainted, offset, flags, 0, this);
#endif
    }

    // Paint the rest with composition.
#ifndef Q_BACKINGSTORE_SUBSURFACES
    if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
        const int flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
        tlw->d_func()->drawWidget(windowSurface->paintDevice(), dirtyCopy, tlwOffset, flags, 0, this);
    }

    endPaint(toClean, windowSurface, &beginPaintInfo);
#else
    if (!repaintAllWidgets && dirtyCopy.isEmpty())
        return; // Nothing more to paint.

    QList<QWindowSurface *> surfaceList(subSurfaces);
    surfaceList.prepend(windowSurface);
    const QRect dirtyBoundingRect(dirtyCopy.boundingRect());

    // Loop through all window surfaces (incl. the top-level surface) and
    // repaint those intersecting with the bounding rect of the dirty region.
    for (int i = 0; i < surfaceList.size(); ++i) {
        QWindowSurface *subSurface = surfaceList.at(i);
        QWidget *w = subSurface->window();
        QWidgetPrivate *wd = w->d_func();

        const QRect clipRect = wd->clipRect().translated(w->mapTo(tlw, QPoint()));
        if (!qRectIntersects(dirtyBoundingRect, clipRect))
            continue;

        toClean = dirtyCopy;
        BeginPaintInfo beginPaintInfo;
        beginPaint(toClean, w, subSurface, &beginPaintInfo);
        if (beginPaintInfo.nothingToPaint)
            continue;

        if (beginPaintInfo.windowSurfaceRecreated) {
            // Eep the window surface has changed. The old one may have been
            // deleted, in which case we will segfault on the call to
            // painterOffset() below. Use the new window surface instead.
            subSurface = w->windowSurface();
        }

        int flags = QWidgetPrivate::DrawRecursive;
        if (w == tlw)
            flags |= QWidgetPrivate::DrawAsRoot;
        const QPoint painterOffset = static_cast<QWSWindowSurface*>(subSurface)->painterOffset();
        wd->drawWidget(subSurface->paintDevice(), toClean, painterOffset, flags, 0, this);

        endPaint(toClean, subSurface, &beginPaintInfo);
    }
#endif
}