void epsExportDialog::accept()
{
QPrinter::Orientation o;
if (boxOrientation->currentItem() == 1)
	o = QPrinter::Portrait;
else
	o = QPrinter::Landscape;
	
QPrinter::ColorMode col = QPrinter::Color;
if (!boxColor->isChecked())
	col = QPrinter::GrayScale;

QPrinter::PageSize size = pageSize();

emit exportToEPS(f_name, boxResolution->value(), o, size, col);
close();
}
Beispiel #2
0
String PrintContext::pageSizeAndMarginsInPixels(LocalFrame* frame,
                                                int pageNumber,
                                                int width,
                                                int height,
                                                int marginTop,
                                                int marginRight,
                                                int marginBottom,
                                                int marginLeft) {
  DoubleSize pageSize(width, height);
  frame->document()->pageSizeAndMarginsInPixels(
      pageNumber, pageSize, marginTop, marginRight, marginBottom, marginLeft);

  return "(" + String::number(floor(pageSize.width())) + ", " +
         String::number(floor(pageSize.height())) + ") " +
         String::number(marginTop) + ' ' + String::number(marginRight) + ' ' +
         String::number(marginBottom) + ' ' + String::number(marginLeft);
}
 FixedVMPoolExecutableAllocator()
     : MetaAllocator(jitAllocationGranule) // round up all allocations to 32 bytes
 {
     size_t reservationSize;
     if (Options::jitMemoryReservationSize())
         reservationSize = Options::jitMemoryReservationSize();
     else
         reservationSize = fixedExecutableMemoryPoolSize;
     reservationSize = roundUpToMultipleOf(pageSize(), reservationSize);
     m_reservation = PageReservation::reserveWithGuardPages(reservationSize, OSAllocator::JSJITCodePages, EXECUTABLE_POOL_WRITABLE, true);
     if (m_reservation) {
         ASSERT(m_reservation.size() == reservationSize);
         addFreshFreeSpace(m_reservation.base(), m_reservation.size());
         
         startOfFixedExecutableMemoryPool = reinterpret_cast<uintptr_t>(m_reservation.base());
     }
 }
Beispiel #4
0
void KPMarginPage::initPageSize(const QString& ps, bool landscape)
{
	// first retrieve the Qt values for page size and margins
	QPrinter	prt(QPrinter::PrinterResolution);
	prt.setFullPage(true);
	prt.setPageSize((QPrinter::PageSize)(ps.isEmpty() ? KGlobal::locale()->pageSize() : ps.toInt()));
	QPaintDeviceMetrics	metrics(&prt);
	float	w = metrics.width();
	float	h = metrics.height();
	unsigned int	it, il, ib, ir;
	prt.margins( &it, &il, &ib, &ir );
	float	mt = it;
	float	ml = il;
	float	mb = ib;
	float	mr = ir;

	if (driver() && m_usedriver )
	{
		QString	pageSize(ps);

		if (pageSize.isEmpty())
		{
			DrListOption	*o = (DrListOption*)driver()->findOption("PageSize");
			if (o)
				pageSize = o->get("default");
		}
		if (!pageSize.isEmpty())
		{
			DrPageSize	*dps = driver()->findPageSize(pageSize);
			if (dps)
			{
				w = dps->pageWidth();
				h = dps->pageHeight();
				mt = QMAX( mt, dps->topMargin() );
				ml = QMAX( ml, dps->leftMargin() );
				mb = QMAX( mb, dps->bottomMargin() );
				mr = QMAX( mr, dps->rightMargin() );
			}
		}
	}
	m_margin->setPageSize(w, h);
	m_margin->setOrientation(landscape ? KPrinter::Landscape : KPrinter::Portrait);
	m_margin->setDefaultMargins( mt, mb, ml, mr );
	m_margin->setCustomEnabled(false);
}
void DocumentWidget::setPageNumber(Q_UINT16 nr)
{
  pageNr = nr;

  selectionNeedsUpdating = true;

  // We have to reset this, because otherwise we might crash in the mouseMoveEvent
  // After switching pages in SinglePageMode or OverviewMode.
  indexOfUnderlinedLink = -1;

  // Resize Widget if the size of the new page is different than the size of the old page.
  QSize _pageSize = documentCache->sizeOfPageInPixel(pageNr);
  if (_pageSize != pageSize())
  {
    setPageSize(_pageSize);
  }
  update();
}
Beispiel #6
0
void* allocateJSBlock(unsigned size)
{
    // See: JavaScriptCore/runtime/Collector.cpp
    OLYMPIA_ASSERT(size == BLOCK_SIZE);
#if defined(OLYMPIA_LINUX) //|| defined(OLYMPIA_MAC)
#if ENABLE(JSC_MULTIPLE_THREADS)
#error Need to initialize pagesize safely.
#endif
    static size_t pagesize = pageSize();

    size_t extra = 0;
    if (BLOCK_SIZE > pagesize)
        extra = BLOCK_SIZE - pagesize;

    void* mmapResult = mmap(NULL, BLOCK_SIZE + extra, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
    uintptr_t address = reinterpret_cast<uintptr_t>(mmapResult);

    size_t adjust = 0;
    if ((address & BLOCK_OFFSET_MASK) != 0)
        adjust = BLOCK_SIZE - (address & BLOCK_OFFSET_MASK);

    if (adjust > 0)
        munmap(reinterpret_cast<char*>(address), adjust);

    if (adjust < extra)
        munmap(reinterpret_cast<char*>(address + adjust + BLOCK_SIZE), extra - adjust);

    address += adjust;
    return reinterpret_cast<void*>(address);
#elif defined(OLYMPIA_WINDOWS)
#if COMPILER(MINGW) && !COMPILER(MINGW64)
    void* address = __mingw_aligned_malloc(BLOCK_SIZE, BLOCK_SIZE);
#else
    void* address = _aligned_malloc(BLOCK_SIZE, BLOCK_SIZE);
#endif
    memset(address, 0, BLOCK_SIZE);
	return address;
#elif defined(OLYMPIA_MAC)
    vm_address_t address = 0;
    vm_map(current_task(), &address, BLOCK_SIZE, BLOCK_OFFSET_MASK, VM_FLAGS_ANYWHERE | VM_TAG_FOR_COLLECTOR_MEMORY, MEMORY_OBJECT_NULL, 0, FALSE, VM_PROT_DEFAULT, VM_PROT_DEFAULT, VM_INHERIT_DEFAULT);
    return reinterpret_cast<void*>(address);
#endif
}
void KPrViewModePreviewShapeAnimations::activate(KoPAViewMode *previousViewMode)
{
    m_savedViewMode = previousViewMode;               // store the previous view mode
    m_animationCache = new KPrAnimationCache();
    m_canvas->shapeManager()->setPaintingStrategy(new KPrShapeManagerAnimationStrategy(m_canvas->shapeManager(),
                                                                                       m_animationCache,
                                                       new KPrPageSelectStrategyActive(m_canvas)));

    // the update of the canvas is needed so that the old page gets drawn fully before the effect starts

    const KoPageLayout &layout = activePageLayout();

    QSizeF pageSize(layout.width, layout.height);

    //calculate size of union page + viewport
    QSizeF documentMinSize(view()->zoomController()->documentSize());

    // create a rect out of it with origin in tp left of page
    QRectF documentRect(QPointF((documentMinSize.width() - layout.width) * -0.5,
                               (documentMinSize.height() - layout.height) * -0.5),
                       documentMinSize);

    QPointF offset = -documentRect.topLeft();
    m_canvas->setDocumentOrigin(offset);
    m_view->zoomController()->setPageSize(pageSize);

    m_canvas->resourceManager()->setResource(KoCanvasResourceManager::PageSize, pageSize);
    m_canvas->repaint();


    m_timeLine.setDuration(m_shapeAnimation->duration());
    m_timeLine.setCurrentTime(0);
    m_animationCache->clear();
    m_animationCache->setPageSize(view()->zoomController()->pageSize());
    qreal zoom;
    view()->zoomHandler()->zoom(&zoom, &zoom);
    m_animationCache->setZoom(zoom);
    m_shapeAnimation->init(m_animationCache, 0);
    m_animationCache->startStep(0);
    m_timeLine.start();
    connect(&m_timeLine, SIGNAL(valueChanged(qreal)), this, SLOT(animate()));
}
Beispiel #8
0
void SQLiteDatabase::setMaximumSize(int64_t size)
{
    if (size < 0)
        size = 0;
    
    int currentPageSize = pageSize();

    ASSERT(currentPageSize);
    int64_t newMaxPageCount = currentPageSize ? size / currentPageSize : 0;
    
    MutexLocker locker(m_authorizerLock);
    enableAuthorizer(false);

    SQLiteStatement statement(*this, "PRAGMA max_page_count = " + String::number(newMaxPageCount));
    statement.prepare();
    if (statement.step() != SQLResultRow)
        LOG_ERROR("Failed to set maximum size of database to %lli bytes", size);

    enableAuthorizer(true);

}
Beispiel #9
0
wxSize wxWizard::GetPageSize() const
{
    // default width and height of the page
    int DEFAULT_PAGE_WIDTH,
        DEFAULT_PAGE_HEIGHT;
    if ( wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA )
    {
        // Make the default page size small enough to fit on screen
        DEFAULT_PAGE_WIDTH = wxSystemSettings::GetMetric(wxSYS_SCREEN_X) / 2;
        DEFAULT_PAGE_HEIGHT = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) / 2;
    }
    else // !PDA
    {
        DEFAULT_PAGE_WIDTH =
        DEFAULT_PAGE_HEIGHT = 270;
    }

    // start with default minimal size
    wxSize pageSize(DEFAULT_PAGE_WIDTH, DEFAULT_PAGE_HEIGHT);

    // make the page at least as big as specified by user
    pageSize.IncTo(m_sizePage);

    if ( m_statbmp )
    {
        // make the page at least as tall as the bitmap
        pageSize.IncTo(wxSize(0, m_bitmap.GetHeight()));
    }

    if ( m_usingSizer )
    {
        // make it big enough to contain all pages added to the sizer
        pageSize.IncTo(m_sizerPage->GetMaxChildSize());
    }

    return pageSize;
}
Beispiel #10
0
bool KDReports::Report::print( QPrinter* printer, QWidget* parent )
{
    // save the old page size
    QPrinter::PageSize savePageSize = pageSize();
    if ( d->wantEndlessPrinting() ) {
        // ensure that the printer is set up with the right size
        d->ensureLayouted();
        printer->setPaperSize( d->m_paperSize, QPrinter::DevicePixel );
    } else {
        // ensure that the layout matches the printer
        d->setPaperSizeFromPrinter( printer->paperRect().size() );
    }

    printer->setFullPage( true );

    // don't call ensureLayouted here, it would use the wrong printer!

    const bool ret = d->doPrint( printer, parent );

    // Reset the page size
    setPageSize( savePageSize );

    return ret;
}
Beispiel #11
0
void BufferManager::loadBuffers() {
	openLogFile();

	__int32 buffers = _controlFile->readInt();

	// The buffers are circular, this means that some
	// buffers are in the front of the control file but
	// they are at the tail of the queue
	std::vector<Buffer*> front;
	std::vector<Buffer*> tail;
	bool addToTail = true;
	for (__int32 x = 0; x < buffers; x++) {
		__int32 controlPosition = _controlFile->currentPos();
		char flag = _controlFile->readChar();
		__int64 startOffset = _controlFile->readLong();
		__int64 bufferLen = _controlFile->readLong();
		char* logFileName = _controlFile->readChars();
		Buffer* buffer = new Buffer(this, logFileName, startOffset, _buffersSize, _buffersSize / pageSize());
		buffer->setControlPosition(controlPosition);

		if (flag & 0x01) {
			if (addToTail) {
				tail.push_back(buffer);
			} else {
				front.push_back(buffer);
			}
		} else {
			addToTail = false;
			addReusable(buffer);
		}
		free(logFileName);
	}
	for (std::vector<Buffer*>::iterator iter = front.begin(); iter != front.end(); iter++) {
		Buffer* buffer = *iter;
		addBuffer(buffer);
	}
	for (std::vector<Buffer*>::iterator iter = tail.begin(); iter != tail.end(); iter++) {
		Buffer* buffer = *iter;
		addBuffer(buffer);
	}
}
Beispiel #12
0
void 
Ndbfs::readWriteRequest(int action, Signal * signal)
{
  const FsReadWriteReq * const fsRWReq = (FsReadWriteReq *)&signal->theData[0];
  Uint16 filePointer =  (Uint16)fsRWReq->filePointer;
  const UintR userPointer = fsRWReq->userPointer; 
  const BlockReference userRef = fsRWReq->userReference;
  const BlockNumber blockNumber = refToBlock(userRef);

  AsyncFile* openFile = theOpenFiles.find(filePointer);

  const NewVARIABLE *myBaseAddrRef = &getBat(blockNumber)[fsRWReq->varIndex];
  UintPtr tPageSize;
  UintPtr tClusterSize;
  UintPtr tNRR;
  UintPtr tPageOffset;
  char*        tWA;
  FsRef::NdbfsErrorCodeType errorCode;

  Request *request = theRequestPool->get();
  request->error = 0;
  request->set(userRef, userPointer, filePointer);
  request->file = openFile;
  request->action = (Request::Action) action;
  request->theTrace = signal->getTrace();

  Uint32 format = fsRWReq->getFormatFlag(fsRWReq->operationFlag);

  if (fsRWReq->numberOfPages == 0) { //Zero pages not allowed
    jam();
    errorCode = FsRef::fsErrInvalidParameters;
    goto error;
  }

  if(format != FsReadWriteReq::fsFormatGlobalPage &&
     format != FsReadWriteReq::fsFormatSharedPage)
  {     
    if (fsRWReq->varIndex >= getBatSize(blockNumber)) {
      jam();// Ensure that a valid variable is used    
      errorCode = FsRef::fsErrInvalidParameters;
      goto error;
    }
    if (myBaseAddrRef == NULL) {
      jam(); // Ensure that a valid variable is used
      errorCode = FsRef::fsErrInvalidParameters;
      goto error;
    }
    if (openFile == NULL) {
      jam(); //file not open
      errorCode = FsRef::fsErrFileDoesNotExist;
      goto error;
    }
    tPageSize = pageSize(myBaseAddrRef);
    tClusterSize = myBaseAddrRef->ClusterSize;
    tNRR = myBaseAddrRef->nrr;
    tWA = (char*)myBaseAddrRef->WA;
    
    switch (format) {
      
      // List of memory and file pages pairs
    case FsReadWriteReq::fsFormatListOfPairs: { 
      jam();
      for (unsigned int i = 0; i < fsRWReq->numberOfPages; i++) {
	jam();
	const UintPtr varIndex = fsRWReq->data.listOfPair[i].varIndex;
	const UintPtr fileOffset = fsRWReq->data.listOfPair[i].fileOffset;
	if (varIndex >= tNRR) {
	  jam();
	  errorCode = FsRef::fsErrInvalidParameters;
	  goto error;
	}//if
	request->par.readWrite.pages[i].buf = &tWA[varIndex * tClusterSize];
	request->par.readWrite.pages[i].size = tPageSize;
	request->par.readWrite.pages[i].offset = fileOffset * tPageSize;
      }//for
      request->par.readWrite.numberOfPages = fsRWReq->numberOfPages;
      break;
    }//case
      
      // Range of memory page with one file page
    case FsReadWriteReq::fsFormatArrayOfPages: { 
      if ((fsRWReq->numberOfPages + fsRWReq->data.arrayOfPages.varIndex) > tNRR) {
        jam();
        errorCode = FsRef::fsErrInvalidParameters;
        goto error;
      }//if
      const UintPtr varIndex = fsRWReq->data.arrayOfPages.varIndex;
      const UintPtr fileOffset = fsRWReq->data.arrayOfPages.fileOffset;
      
      request->par.readWrite.pages[0].offset = fileOffset * tPageSize;
      request->par.readWrite.pages[0].size = tPageSize * fsRWReq->numberOfPages;
      request->par.readWrite.numberOfPages = 1;
      request->par.readWrite.pages[0].buf = &tWA[varIndex * tPageSize];
      break;
    }//case
      
      // List of memory pages followed by one file page
    case FsReadWriteReq::fsFormatListOfMemPages: { 
      
      tPageOffset = fsRWReq->data.listOfMemPages.varIndex[fsRWReq->numberOfPages];
      tPageOffset *= tPageSize;
      
      for (unsigned int i = 0; i < fsRWReq->numberOfPages; i++) {
	jam();
	UintPtr varIndex = fsRWReq->data.listOfMemPages.varIndex[i];
	
	if (varIndex >= tNRR) {
	  jam();
	  errorCode = FsRef::fsErrInvalidParameters;
	  goto error;
	}//if
	request->par.readWrite.pages[i].buf = &tWA[varIndex * tClusterSize];
	request->par.readWrite.pages[i].size = tPageSize;
	request->par.readWrite.pages[i].offset = tPageOffset + (i*tPageSize);
      }//for
      request->par.readWrite.numberOfPages = fsRWReq->numberOfPages;
      break;
      // make it a writev or readv
    }//case
      
    default: {
      jam();
      errorCode = FsRef::fsErrInvalidParameters;
      goto error;
    }//default
    }//switch
  } 
  else if (format == FsReadWriteReq::fsFormatGlobalPage)
  {
    Ptr<GlobalPage> ptr;
    m_global_page_pool.getPtr(ptr, fsRWReq->data.pageData[0]);
    request->par.readWrite.pages[0].buf = (char*)ptr.p;
    request->par.readWrite.pages[0].size = ((UintPtr)GLOBAL_PAGE_SIZE)*fsRWReq->numberOfPages;
    request->par.readWrite.pages[0].offset= ((UintPtr)GLOBAL_PAGE_SIZE)*fsRWReq->varIndex;
    request->par.readWrite.numberOfPages = 1;
  }
  else
  {
    ndbrequire(format == FsReadWriteReq::fsFormatSharedPage);
    Ptr<GlobalPage> ptr;
    m_shared_page_pool.getPtr(ptr, fsRWReq->data.pageData[0]);
    request->par.readWrite.pages[0].buf = (char*)ptr.p;
    request->par.readWrite.pages[0].size = ((UintPtr)GLOBAL_PAGE_SIZE)*fsRWReq->numberOfPages;
    request->par.readWrite.pages[0].offset= ((UintPtr)GLOBAL_PAGE_SIZE)*fsRWReq->varIndex;
    request->par.readWrite.numberOfPages = 1;
  }
  
  ndbrequire(forward(openFile, request));
  return;
  
error:
  theRequestPool->put(request);
  FsRef * const fsRef = (FsRef *)&signal->theData[0];
  fsRef->userPointer = userPointer;
  fsRef->setErrorCode(fsRef->errorCode, errorCode);
  fsRef->osErrorCode = ~0; // Indicate local error
  switch (action) {
  case Request:: write:
  case Request:: writeSync: {
    jam();
    sendSignal(userRef, GSN_FSWRITEREF, signal, 3, JBB);
    break;
  }//case
  case Request:: readPartial: 
  case Request:: read: {
    jam();
    sendSignal(userRef, GSN_FSREADREF, signal, 3, JBB);
  }//case
  }//switch
  return;
}
Beispiel #13
0
Buffer* BufferManager::createNewBuffer() {
	Buffer* result = new Buffer(this, _logFileName, _buffersCount * _buffersSize, (__int64)0, _buffersSize / pageSize());
	return result;
}
Beispiel #14
0
 virtual void notifyNeedPage(void* page)
 {
     m_reservation.commit(page, pageSize());
 }
void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bool executable, bool includesGuardPages)
{
    // All POSIX reservations start out logically committed.
    int protection = PROT_READ;
    if (writable)
        protection |= PROT_WRITE;
    if (executable)
        protection |= PROT_EXEC;

    int flags = MAP_PRIVATE | MAP_ANON;
#if PLATFORM(IOS)
    if (executable)
        flags |= MAP_JIT;
#endif

#if OS(DARWIN)
    int fd = usage;
#else
    UNUSED_PARAM(usage);
    int fd = -1;
#endif

    void* result = 0;
#if (OS(DARWIN) && CPU(X86_64))
    if (executable) {
        ASSERT(includesGuardPages);
        // Cook up an address to allocate at, using the following recipe:
        //   17 bits of zero, stay in userspace kids.
        //   26 bits of randomness for ASLR.
        //   21 bits of zero, at least stay aligned within one level of the pagetables.
        //
        // But! - as a temporary workaround for some plugin problems (rdar://problem/6812854),
        // for now instead of 2^26 bits of ASLR lets stick with 25 bits of randomization plus
        // 2^24, which should put up somewhere in the middle of userspace (in the address range
        // 0x200000000000 .. 0x5fffffffffff).
        intptr_t randomLocation = 0;
        randomLocation = arc4random() & ((1 << 25) - 1);
        randomLocation += (1 << 24);
        randomLocation <<= 21;
        result = reinterpret_cast<void*>(randomLocation);
    }
#endif

    result = mmap(result, bytes, protection, flags, fd, 0);
    if (result == MAP_FAILED) {
#if ENABLE(LLINT)
        if (executable)
            result = 0;
        else
#endif
            CRASH();
    }
    if (result && includesGuardPages) {
        // We use mmap to remap the guardpages rather than using mprotect as
        // mprotect results in multiple references to the code region.  This
        // breaks the madvise based mechanism we use to return physical memory
        // to the OS.
        mmap(result, pageSize(), PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, fd, 0);
        mmap(static_cast<char*>(result) + bytes - pageSize(), pageSize(), PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, fd, 0);
    }
    return result;
}
Beispiel #16
0
void Text::layout()
      {
#if 0
      QSizeF pageSize(-1.0, 1000000);
      setPos(0.0, 0.0);
      if (parent() && _layoutToParentWidth) {
            pageSize.setWidth(parent()->width());
            if (parent()->type() == HBOX || parent()->type() == VBOX || parent()->type() == TBOX) {
                  Box* box = static_cast<Box*>(parent());
                  rxpos() += box->leftMargin() * DPMM;
                  rypos() += box->topMargin() * DPMM;
                  // pageSize.setHeight(box->height() - (box->topMargin() + box->bottomMargin()) * DPMM);
                  pageSize.setWidth(box->width()   - (box->leftMargin() + box->rightMargin()) * DPMM);
                  }
            }

      QTextOption to = _doc->defaultTextOption();
      to.setUseDesignMetrics(true);
      to.setWrapMode(pageSize.width() <= 0.0 ? QTextOption::NoWrap : QTextOption::WrapAtWordBoundaryOrAnywhere);
      _doc->setDefaultTextOption(to);

      if (pageSize.width() <= 0.0)
            _doc->setTextWidth(_doc->idealWidth());
      else
            _doc->setPageSize(pageSize);

      if (hasFrame()) {
            frame = QRectF();
            for (QTextBlock tb = _doc->begin(); tb.isValid(); tb = tb.next()) {
                  QTextLayout* tl = tb.layout();
                  int n = tl->lineCount();
                  for (int i = 0; i < n; ++i)
                        // frame |= tl->lineAt(0).naturalTextRect().translated(tl->position());
                        frame |= tl->lineAt(0).rect().translated(tl->position());
                  }
            if (circle()) {
                  if (frame.width() > frame.height()) {
                        frame.setY(frame.y() + (frame.width() - frame.height()) * -.5);
                        frame.setHeight(frame.width());
                        }
                  else {
                        frame.setX(frame.x() + (frame.height() - frame.width()) * -.5);
                        frame.setWidth(frame.height());
                        }
                  }
            qreal w = (paddingWidth() + frameWidth() * .5) * DPMM;
            frame.adjust(-w, -w, w, w);
            w = frameWidth() * DPMM;
            _bbox = frame.adjusted(-w, -w, w, w);
            }
      else {
            _bbox = QRectF(QPointF(0.0, 0.0), _doc->size()); //_doc->documentLayout()->frameBoundingRect(_doc->rootFrame());
            }
      _doc->setModified(false);
      style().layout(this);      // process alignment

      if ((style().align() & ALIGN_VCENTER) && (subtype() == TEXT_TEXTLINE)) {
            // special case: vertically centered text with TextLine needs to
            // take into account the line width
            TextLineSegment* tls = (TextLineSegment*)parent();
            TextLine* tl = (TextLine*)(tls->line());
            qreal textlineLineWidth = point(tl->lineWidth());
            rypos() -= textlineLineWidth * .5;
            }

      if (parent() == 0)
            return;
      if (parent()->type() == SEGMENT) {
            Segment* s = static_cast<Segment*>(parent());
            rypos() += s ? s->measure()->system()->staff(staffIdx())->y() : 0.0;
            }
#endif
      Font f = style().font(spatium());
      qreal asc, desc, leading;
      qreal w = textMetrics(f.family(), _text, f.size(), &asc, &desc, &leading);

// printf("text(%s) asc %f desc %f leading %f  w %f\n", qPrintable(_text), asc, desc, leading, w);
      _lineHeight  = asc + desc;
      _lineSpacing = _lineHeight + leading;
      _baseLine    = asc;

      setbbox(QRectF(0.0, -asc, w, _lineHeight));
#if 0
      if (parent() && _layoutToParentWidth) {
            qreal wi = parent()->width();
            qreal ph = parent()->height();
            qreal x;
            qreal y = pos.y();
            if (align() & ALIGN_HCENTER)
                  x = (wi - w) * .5;
            else if (align() & ALIGN_RIGHT)
                  x = wi - w;
            else
                  x = 0.0;
            if (align() & ALIGN_VCENTER)
                  y = (ph - asc) * .5;
            else if (align() & ALIGN_BOTTOM)
                  y = ph - asc;
            else
                  y = asc;
            setPos(x, y + asc);
            }
#endif
      style().layout(this);      // process alignment
      rypos() += asc;

      if (parent() && _layoutToParentWidth) {
            qreal wi = parent()->width();
            if (align() & ALIGN_HCENTER)
                  rxpos() = (wi - w) * .5;
            else if (align() & ALIGN_RIGHT)
                  rxpos() = wi - w;
            }

      if ((style().align() & ALIGN_VCENTER) && (subtype() == TEXT_TEXTLINE)) {
            // special case: vertically centered text with TextLine needs to
            // take into account the line width
            TextLineSegment* tls = (TextLineSegment*)parent();
            TextLine* tl = (TextLine*)(tls->line());
            qreal textlineLineWidth = point(tl->lineWidth());
            rypos() -= textlineLineWidth * .5;
            }

      if (parent() == 0)
            return;
      if (parent()->type() == SEGMENT) {
            Segment* s = static_cast<Segment*>(parent());
            rypos() += s ? s->measure()->system()->staff(staffIdx())->y() : 0.0;
            }
      }
Beispiel #17
0
void TFuncSpecView::Paint(TDC& dc, bool erase, TRect& rect)
{
  TSwitchMinApp* theApp = TYPESAFE_DOWNCAST(GetApplication(), TSwitchMinApp);
  if (theApp) {
    // Only paint if we're printing and we have something to paint, otherwise do nothing.
    //
    if (theApp->Printing && theApp->Printer && !rect.IsEmpty()) {
      // Use pageSize to get the size of the window to render into.  For a Window it's the client area,
      // for a printer it's the printer DC dimensions and for print preview it's the layout window.
      //
      TSize   pageSize(rect.right - rect.left, rect.bottom - rect.top);

      TPrintDialog::TData& printerData = theApp->Printer->GetSetup();

      // Get area we can draw in
      TRect drawingArea(swdoc->PaintHeader(dc, rect, "", 0, 0, false), rect.BottomRight());

      TEXTMETRIC tm;
      dc.SelectObject(TFont("Arial", -12));
      if (!dc.GetTextMetrics(tm)) {
        dc.SelectObject(TFont("Arial", -12));
        dc.GetTextMetrics(tm);
      }
      int fHeight=tm.tmHeight+tm.tmExternalLeading;

      unsigned long inputs=swdoc->GetSystem()->GetInputs();

      XPosVector xpos;
      uint divider;
      char* data;

      Print_CreateWidths(xpos, divider, dc);
      if (xpos.back().x < rect.Size().cx) {  // put space in structure to stretch across page
        uint spacing=(rect.Size().cx - xpos.back().x)/(xpos.size()+1);
        uint space_inc=spacing;
        for(XPosVector::size_type i=0; i<xpos.size(); i++) {
          if (i==inputs) {  // after inputs section, increase divider
            divider += space_inc;
            space_inc += spacing;
          }
          xpos[i].x += space_inc;
          space_inc += spacing;
        }
      }

      data=new char[xpos.size()];

      unsigned long PagesDown=1+pow(2,inputs)/( (drawingArea.Size().cy/fHeight) - 2);  // 2 lines for header and horz divider
      unsigned long PagesAcross=1+xpos.back().x/drawingArea.Size().cx;
      unsigned long Pages=1+PagesDown*PagesAcross;

      // Compute the number of pages to print.
      //
      printerData.MinPage = 1;
      printerData.MaxPage = Pages;


      int fromPage = printerData.FromPage == -1 ? 1 : printerData.FromPage;
      int toPage = printerData.ToPage == -1 ? 1 : printerData.ToPage;
      int currentPage = fromPage;

      TPoint p;

      dc.SelectObject(TPen(TColor::Black));

      while (currentPage <= toPage) {
        swdoc->PaintHeader(dc, rect, "Specification", currentPage, Pages, true);
        if (currentPage==1) Print_Summary(dc, drawingArea);
        else {
          // Calculate origin of line by page number
            // x
            int col=((currentPage-2) ) % PagesAcross;
            p.x=drawingArea.left - col * drawingArea.Size().cx;
            // y
            int row=floor((currentPage-2)/PagesAcross);
            p.y=drawingArea.top/* - row * drawingArea.Size().cy*/;

          // Calculate starting and ending input states
          CELL_TYPE state, stateEnd;
          state=(row*(drawingArea.Size().cy-fHeight))/fHeight;
          stateEnd=state+(drawingArea.Size().cy-fHeight)/fHeight;
          if (stateEnd >= (pow(2,inputs)-1) ) stateEnd=pow(2,inputs)-1;

          //
          // Draw header and lines

          // Vertical
          if ( ((p.x+divider) > drawingArea.left) && ((p.x+divider)<drawingArea.right) ) {
            dc.MoveTo(p.x+divider, p.y);
            dc.LineTo(p.x+divider, p.y+((stateEnd-state)+3)*fHeight);
          }

          // Labels
          for(XPosVector::size_type i=0; i<xpos.size(); i++)
            dc.TextOut(TPoint(xpos[i].x, p.y), xpos[i].s.c_str());
          p.y += fHeight;

          // Horizontal
          dc.MoveTo(drawingArea.left, p.y + fHeight/2);
          dc.LineTo(p.x+xpos.back().x, p.y + fHeight/2);
          p.y += fHeight;

          //
          // Draw each line
          while(state <= stateEnd) {
            Print_GenerateLine(data, state);
            Print_Line(dc, p, xpos, data);
            p.y += fHeight;
            state++;
          }
        }

        currentPage++;
      }

      delete[] data;
    }
    else {
      // INSERT>> Normal painting code goes here.
      wTabs->InvalidateRect(rect, erase);
    }
  }
}
Beispiel #18
0
 virtual void notifyPageIsFree(void* page)
 {
     m_reservation.decommit(page, pageSize());
 }
Beispiel #19
0
//
// Paint routine for Window, Printer, and PrintPreview for a TEdit/TListBox client.
//
void poundsMDIChild::Paint (TDC& dc, BOOL, TRect& rect)
{
    poundsApp *theApp = TYPESAFE_DOWNCAST(GetApplication(), poundsApp);
    if (theApp) {
        // Only paint if we're printing and we have something to paint, otherwise do nothing.
        if (theApp->Printing && theApp->Printer && !rect.IsEmpty()) {
            // Use pageSize to get the size of the window to render into.  For a Window it's the client area,
            // for a printer it's the printer DC dimensions and for print preview it's the layout window.
            TSize   pageSize(rect.right - rect.left, rect.bottom - rect.top);

            HFONT   hFont = (HFONT)GetClientWindow()->GetWindowFont();
            TFont   font("Arial", -12);
            if (hFont == 0)
              dc.SelectObject(font);
            else
              dc.SelectObject(TFont(hFont));

            TEXTMETRIC  tm;
            int fHeight = (dc.GetTextMetrics(tm) == TRUE) ? tm.tmHeight + tm.tmExternalLeading : 10;

            // How many lines of this font can we fit on a page.
            int linesPerPage = MulDiv(pageSize.cy, 1, fHeight);
            if (linesPerPage) {
                TPrintDialog::TData &printerData = theApp->Printer->GetSetup();

                int maxPg = 1;

                // Get the client class window (this is the contents we're going to print).
                TEdit *clientEditWindow /* = 0*/;
                TListBox *clientListWindow = 0;
                TWindow *clientUnknownWindow = 0;

                clientEditWindow = TYPESAFE_DOWNCAST(GetClientWindow(), TEdit);
                if (clientEditWindow)
                    maxPg = ((clientEditWindow->GetNumLines() / linesPerPage) + 1.0);
                else {
                    clientListWindow = TYPESAFE_DOWNCAST(GetClientWindow(), TListBox);
                    if (clientListWindow)
                        maxPg = ((clientListWindow->GetCount() / linesPerPage) + 1.0);
                    else
                       clientUnknownWindow = TYPESAFE_DOWNCAST(GetClientWindow(), TWindow);
                }

                // Compute the number of pages to print.
                printerData.MinPage = 1;
                printerData.MaxPage = maxPg;

                // Do the text stuff:
                int     fromPage = printerData.FromPage == -1 ? 1 : printerData.FromPage;
                int     toPage = printerData.ToPage == -1 ? 1 : printerData.ToPage;
                char    buffer[255];
                int     currentPage = fromPage;

                while (currentPage <= toPage) {
                    int startLine = (currentPage - 1) * linesPerPage;
                    int lineIdx = 0;
                    while (lineIdx < linesPerPage) {
                        // If the string is no longer valid then there's nothing more to display.
                        if (clientEditWindow) {
                            if (!clientEditWindow->GetLine(buffer, sizeof(buffer), startLine + lineIdx))
                                break;
                        }
                        else if (clientListWindow) {
                            if (clientListWindow->GetString(buffer, startLine + lineIdx) < 0)
                                break;
                        }
                        else if (clientUnknownWindow) {
                           clientUnknownWindow->Paint(dc, FALSE, rect);
                           break;
                        }
                        dc.TabbedTextOut(TPoint(0, lineIdx * fHeight), buffer, lstrlen(buffer), 0, NULL, 0);
                        lineIdx++;
                    }
                    currentPage++;
                }
            }
        }
    }
}
void* OSAllocator::reserveAndCommit(size_t bytes, Usage usage, bool writable, bool executable, bool includesGuardPages)
{
    // All POSIX reservations start out logically committed.
    int protection = PROT_READ;
    if (writable)
        protection |= PROT_WRITE;
    if (executable)
        protection |= PROT_EXEC;

    int flags = MAP_PRIVATE | MAP_ANON;
#if PLATFORM(IOS)
    if (executable)
        flags |= MAP_JIT;
#endif

#if OS(LINUX)
    // Linux distros usually do not allow overcommit by default, so
    // JSC's strategy of mmaping a large amount of memory upfront
    // won't work very well on some systems. Fortunately there's a
    // flag we can pass to mmap to disable the overcommit check for
    // this particular call, so we can get away with it as long as the
    // overcommit flag value in /proc/sys/vm/overcommit_memory is 0
    // ('heuristic') and not 2 (always check). 0 is the usual default
    // value, so this should work well in general.
    flags |= MAP_NORESERVE;
#endif

#if OS(DARWIN)
    int fd = usage;
#else
    int fd = -1;
#endif

    void* result = 0;
#if (OS(DARWIN) && CPU(X86_64))
    if (executable) {
        ASSERT(includesGuardPages);
        // Cook up an address to allocate at, using the following recipe:
        //   17 bits of zero, stay in userspace kids.
        //   26 bits of randomness for ASLR.
        //   21 bits of zero, at least stay aligned within one level of the pagetables.
        //
        // But! - as a temporary workaround for some plugin problems (rdar://problem/6812854),
        // for now instead of 2^26 bits of ASLR lets stick with 25 bits of randomization plus
        // 2^24, which should put up somewhere in the middle of userspace (in the address range
        // 0x200000000000 .. 0x5fffffffffff).
        intptr_t randomLocation = 0;
        randomLocation = arc4random() & ((1 << 25) - 1);
        randomLocation += (1 << 24);
        randomLocation <<= 21;
        result = reinterpret_cast<void*>(randomLocation);
    }
#endif

    result = mmap(result, bytes, protection, flags, fd, 0);
    if (result == MAP_FAILED) {
    #if ENABLE(INTERPRETER)
        if (executable)
            result = 0;
        else
    #endif
            CRASH();
    }
    if (result && includesGuardPages) {
        // We use mmap to remap the guardpages rather than using mprotect as
        // mprotect results in multiple references to the code region.  This
        // breaks the madvise based mechanism we use to return physical memory
        // to the OS.
        mmap(result, pageSize(), PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, fd, 0);
        mmap(static_cast<char*>(result) + bytes - pageSize(), pageSize(), PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, fd, 0);
    }
    return result;
}
/*!
    \reimp
 */
void HbScrollBar::mousePressEvent( QGraphicsSceneMouseEvent *event )
{
    Q_D(HbScrollBar);
    QGraphicsWidget::mousePressEvent(event);

    if ( !d->mInteractive ) {
        return;
    }

    HbStyleOptionScrollBar opt;

    QRectF handleBounds = d->handleItem->boundingRect();

    d->mPressPosition = mapToItem(d->handleItem, event->pos());

    switch (orientation()) {
    case Qt::Horizontal:
        d->mThumbPressed = (event->pos().x() >= d->handleItem->pos().x() &&
                            event->pos().x() <= d->handleItem->pos().x() + handleBounds.width());
        if (!d->mThumbPressed) {
            d->mGroovePressed = true;
            HbWidgetFeedback::triggered(this, Hb::InstantPressed);

            if (d->handleItem->pos().x() < event->pos().x()) {
                emit valueChangeRequested(qMin(value() + pageSize(), qreal(1.0)), orientation());
            } else {
                emit valueChangeRequested(qMax(value() - pageSize(), qreal(0.0)), orientation());
            }
            d->mPressedTargetValue = qBound(qreal(0.0),
                                            qreal((event->pos().x() - (handleBounds.width() / 2.0)) / (boundingRect().width() - handleBounds.width())),
                                            qreal(1.0));

            d->repeatActionTimer.start(REPEATION_TIME, this);
        } else {
            HbWidgetFeedback::triggered(this, Hb::InstantPressed, Hb::ModifierSliderHandle);
            initStyleOption(&opt);
            style()->updatePrimitive(d->handleItem, HbStyle::P_ScrollBar_handle, &opt );
            emit d->core.handlePressed();
        }

        break;
    case Qt::Vertical:
        d->mThumbPressed = (event->pos().y() >= d->handleItem->pos().y() &&
                            event->pos().y() <= d->handleItem->pos().y() + handleBounds.height());
        if (!d->mThumbPressed) {
            d->mGroovePressed = true;
            HbWidgetFeedback::triggered(this, Hb::InstantPressed);

            if (d->handleItem->pos().y() < event->pos().y()) {
                emit valueChangeRequested(qMin(value() + pageSize(), qreal(1.0)), orientation());
            } else {
                emit valueChangeRequested(qMax(value() - pageSize(), qreal(0.0)), orientation());
            }

            d->mPressedTargetValue = qBound(qreal(0.0),
                                            qreal((event->pos().y() - (handleBounds.height() / 2.0)) / (boundingRect().height() - handleBounds.height())),
                                            qreal(1.0));

            d->repeatActionTimer.start(REPEATION_TIME, this);
        } else {
            HbWidgetFeedback::triggered(this, Hb::InstantPressed, Hb::ModifierSliderHandle);
            initStyleOption(&opt);
            style()->updatePrimitive(d->handleItem, HbStyle::P_ScrollBar_handle, &opt );
            emit d->core.handlePressed();
        }

        break;
    }
    event->accept();
}
Beispiel #22
0
 virtual void notifyNeedPage(void* page)
 {
     OSAllocator::commit(page, pageSize(), EXECUTABLE_POOL_WRITABLE, true);
 }
int QTextDocument::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: contentsChange((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 1: contentsChanged(); break;
        case 2: undoAvailable((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 3: redoAvailable((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 4: undoCommandAdded(); break;
        case 5: modificationChanged((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 6: cursorPositionChanged((*reinterpret_cast< const QTextCursor(*)>(_a[1]))); break;
        case 7: blockCountChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 8: documentLayoutChanged(); break;
        case 9: undo(); break;
        case 10: redo(); break;
        case 11: appendUndoItem((*reinterpret_cast< QAbstractUndoItem*(*)>(_a[1]))); break;
        case 12: setModified((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 13: setModified(); break;
        }
        _id -= 14;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< bool*>(_v) = isUndoRedoEnabled(); break;
        case 1: *reinterpret_cast< bool*>(_v) = isModified(); break;
        case 2: *reinterpret_cast< QSizeF*>(_v) = pageSize(); break;
        case 3: *reinterpret_cast< QFont*>(_v) = defaultFont(); break;
        case 4: *reinterpret_cast< bool*>(_v) = useDesignMetrics(); break;
        case 5: *reinterpret_cast< QSizeF*>(_v) = size(); break;
        case 6: *reinterpret_cast< qreal*>(_v) = textWidth(); break;
        case 7: *reinterpret_cast< int*>(_v) = blockCount(); break;
        case 8: *reinterpret_cast< qreal*>(_v) = indentWidth(); break;
        case 9: *reinterpret_cast< QString*>(_v) = defaultStyleSheet(); break;
        case 10: *reinterpret_cast< int*>(_v) = maximumBlockCount(); break;
        }
        _id -= 11;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setUndoRedoEnabled(*reinterpret_cast< bool*>(_v)); break;
        case 1: setModified(*reinterpret_cast< bool*>(_v)); break;
        case 2: setPageSize(*reinterpret_cast< QSizeF*>(_v)); break;
        case 3: setDefaultFont(*reinterpret_cast< QFont*>(_v)); break;
        case 4: setUseDesignMetrics(*reinterpret_cast< bool*>(_v)); break;
        case 6: setTextWidth(*reinterpret_cast< qreal*>(_v)); break;
        case 8: setIndentWidth(*reinterpret_cast< qreal*>(_v)); break;
        case 9: setDefaultStyleSheet(*reinterpret_cast< QString*>(_v)); break;
        case 10: setMaximumBlockCount(*reinterpret_cast< int*>(_v)); break;
        }
        _id -= 11;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 11;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Beispiel #24
0
void initializeOptions()
{
    SET(useJIT, true);
    
    SET(showDisassembly, false);
    SET(showDFGDisassembly, false);
    
    SET(maximumOptimizationCandidateInstructionCount, 10000);
    
    SET(maximumFunctionForCallInlineCandidateInstructionCount, 180);
    SET(maximumFunctionForConstructInlineCandidateInstructionCount, 100);
    
    SET(maximumInliningDepth, 5);

    SET(thresholdForJITAfterWarmUp,     100);
    SET(thresholdForJITSoon,            100);

    SET(thresholdForOptimizeAfterWarmUp,     1000);
    SET(thresholdForOptimizeAfterLongWarmUp, 5000);
    SET(thresholdForOptimizeSoon,            1000);

    SET(executionCounterIncrementForLoop,   1);
    SET(executionCounterIncrementForReturn, 15);

    SET(desiredSpeculativeSuccessFailRatio, 6);
    
    SET(likelyToTakeSlowCaseThreshold,    0.15);
    SET(couldTakeSlowCaseThreshold,       0.05); // Shouldn't be zero because some ops will spuriously take slow case, for example for linking or caching.
    SET(likelyToTakeSlowCaseMinimumCount, 100);
    SET(couldTakeSlowCaseMinimumCount,    10);
    
    SET(osrExitProminenceForFrequentExitSite, 0.3);

    SET(largeFailCountThresholdBase,         20);
    SET(largeFailCountThresholdBaseForLoop,  1);
    SET(forcedOSRExitCountForReoptimization, 250);

    SET(reoptimizationRetryCounterStep, 1);

    SET(minimumOptimizationDelay,   1);
    SET(maximumOptimizationDelay,   5);
    SET(desiredProfileLivenessRate, 0.75);
    SET(desiredProfileFullnessRate, 0.35);
    
    SET(doubleVoteRatioForDoubleFormat, 2);
    
    SET(minimumNumberOfScansBetweenRebalance, 100);
    SET(gcMarkStackSegmentSize,               pageSize());
    SET(opaqueRootMergeThreshold,             1000);
    SET(numberOfGCMarkers, computeNumberOfGCMarkers(7)); // We don't scale so well beyond 7.

    ASSERT(thresholdForOptimizeAfterLongWarmUp >= thresholdForOptimizeAfterWarmUp);
    ASSERT(thresholdForOptimizeAfterWarmUp >= thresholdForOptimizeSoon);
    ASSERT(thresholdForOptimizeAfterWarmUp >= 0);
    
    // Compute the maximum value of the reoptimization retry counter. This is simply
    // the largest value at which we don't overflow the execute counter, when using it
    // to left-shift the execution counter by this amount. Currently the value ends
    // up being 18, so this loop is not so terrible; it probably takes up ~100 cycles
    // total on a 32-bit processor.
    reoptimizationRetryCounterMax = 0;
    while ((static_cast<int64_t>(thresholdForOptimizeAfterLongWarmUp) << (reoptimizationRetryCounterMax + 1)) <= static_cast<int64_t>(std::numeric_limits<int32_t>::max()))
        reoptimizationRetryCounterMax++;
    
    ASSERT((static_cast<int64_t>(thresholdForOptimizeAfterLongWarmUp) << reoptimizationRetryCounterMax) > 0);
    ASSERT((static_cast<int64_t>(thresholdForOptimizeAfterLongWarmUp) << reoptimizationRetryCounterMax) <= static_cast<int64_t>(std::numeric_limits<int32_t>::max()));
}
Beispiel #25
0
void* SuperRegion::getAlignedBase(PageReservation& reservation)
{
    for (char* current = static_cast<char*>(reservation.base()); current < static_cast<char*>(reservation.base()) + Region::s_regionSize; current += pageSize()) {
        if (!(reinterpret_cast<size_t>(current) & ~Region::s_regionMask))
            return current;
    }
    ASSERT_NOT_REACHED();
    return 0;
}
Beispiel #26
0
int KLocale::pageSize() const
{
    return d->pageSize();
}
Beispiel #27
0
void QPrinter::setPageOrder( PageOrder newPageOrder )
{
    page_size = makepagesize( pageSize(), newPageOrder, colorMode() );
}
Beispiel #28
0
 virtual void notifyPageIsFree(void* page)
 {
     OSAllocator::decommit(page, pageSize());
 }
Beispiel #29
0
int QPrinter::metric(int m) const
{
  int val = 1;
  switch (m) {
    case QPaintDeviceMetrics::PdmWidth: {
      bool orientInSync = true;
      PMOrientation o;
      QPrinter::Orientation tmpOrient = orientation();
      if (PMGetOrientation(pformat, &o) == noErr) {
        orientInSync = ((o == kPMPortrait && tmpOrient == Portrait)
                        || o == kPMLandscape && tmpOrient == Landscape);
      }
      PageSize s = pageSize();
      if (s >= QPrinter::Custom) {
        val = tmpOrient == Portrait ? customPaperSize_.width() : customPaperSize_.height();
      } else {
        if (state == PST_ACTIVE || (tmpOrient == Portrait || orientInSync)) {
          val = qt_get_PDMWidth(pformat, fullPage());
        } else {
          val = qt_get_PDMHeight(pformat, fullPage());
        }
      }
      break;
    }
    case QPaintDeviceMetrics::PdmHeight: {
      bool orientInSync = true;
      PMOrientation o;
      QPrinter::Orientation tmpOrient = orientation();
      if (PMGetOrientation(pformat, &o) == noErr) {
        orientInSync = ((o == kPMPortrait && tmpOrient == Portrait)
                        || o == kPMLandscape && tmpOrient == Landscape);
      }
      PageSize s = pageSize();
      if (s >= QPrinter::Custom) {
        val = tmpOrient == Portrait ? customPaperSize_.height() : customPaperSize_.width();
      } else {
        if (state == PST_ACTIVE || (tmpOrient == Portrait || orientInSync)) {
          val = qt_get_PDMHeight(pformat, fullPage());
        } else {
          val = qt_get_PDMWidth(pformat, fullPage());
        }
      }
      break;
    }
    // We don't have to worry about the printer state here as metric() does that for us.
    case QPaintDeviceMetrics::PdmWidthMM:
      val = metric(QPaintDeviceMetrics::PdmWidth);
      val = (val * 254 + 5 * res) / (10 * res);
      break;
    case QPaintDeviceMetrics::PdmHeightMM:
      val = metric(QPaintDeviceMetrics::PdmHeight);
      val = (val * 254 + 5 * res) / (10 * res);
      break;
    case QPaintDeviceMetrics::PdmPhysicalDpiX:
    case QPaintDeviceMetrics::PdmPhysicalDpiY: {
      PMPrinter printer;
      if (PMSessionGetCurrentPrinter(psession, &printer) == noErr) {
        PMResolution resolution;
        PMPrinterGetPrinterResolution(printer, kPMCurrentValue, &resolution);
        val = (int)resolution.vRes;
        break;
      }
      //otherwise fall through
    }
    case QPaintDeviceMetrics::PdmDpiY:
    case QPaintDeviceMetrics::PdmDpiX:
      val = res;
      break;
    case QPaintDeviceMetrics::PdmNumColors:
      val = (1 << metric(QPaintDeviceMetrics::PdmDepth));
      break;
    case QPaintDeviceMetrics::PdmDepth:
      val = 24;
      break;
    default:
      val = 0;
#if defined(QT_CHECK_RANGE)
      qWarning("Qt: QPixmap::metric: Invalid metric command");
#endif
  }
  return val;
}
Beispiel #30
0
void QPrinter::setColorMode( ColorMode newColorMode )
{
    page_size = makepagesize( pageSize(), pageOrder(), newColorMode );
}