示例#1
0
void QPEApplication::showWidget( QWidget* wg, bool nomax ) {
    if ( wg->isVisible() ) {
        wg->show();
        return;
    }

    if ( !isSaveWindowsPos() || (!nomax
         && ( qApp->desktop()->width() <= 320 )) ){
        wg->showMaximized();
    } else {
#ifdef Q_WS_QWS
        QSize desk = QSize( qApp->desktop()->width(), qApp->desktop()->height() );
#else
        QSize desk = QSize( qt_maxWindowRect.width(), qt_maxWindowRect.height() );
#endif

        QSize sh = wg->sizeHint();
        int w = QMAX( sh.width(), wg->width() );
        int h = QMAX( sh.height(), wg->height() );
//              desktop                              widget-frame                      taskbar
        w = QMIN( w, ( desk.width() - ( wg->frameGeometry().width() - wg->geometry().width() ) - 25 ) );
        h = QMIN( h, ( desk.height() - ( wg->frameGeometry().height() - wg->geometry().height() ) - 25 ) );
        wg->resize( w, h );
        wg->show();
    }
}
示例#2
0
static QDateTime set(QDateTime dt, PeriodType::Base b, const Duration &dur = Duration())
{
	switch(b)
	{
	case PeriodType::Min:
		dt.setTime(QTime(dt.time().hour(), dt.time().minute(), dur.time.second()));
		break;
	case PeriodType::Hour:
		if(dt.time().minute() || dt.time().second())
			dt.setTime(QTime(dt.time().hour(), dur.time.minute(), dur.time.second()));
		break;
	case PeriodType::Day:
		dt.setTime(dur.time);
		break;
	case PeriodType::Month:
		dt.setDate(QDate(dt.date().year(), dt.date().month(),
			QMIN(QDate(dt.date().year(), dt.date().month(), 1).daysInMonth(), dur.days)));
		dt.setTime(dur.time);
		break;
	case PeriodType::Year:
		dt.setDate(QDate(dt.date().year(), dur.months,
			QMIN(QDate(dt.date().year(), dur.months, 1).daysInMonth(), dur.days)));
		dt.setTime(dur.time);
		break;
	default:;
	}
	return dt;
}
示例#3
0
static int dock_extent( QDockWindow *w, Qt::Orientation o, int maxsize )
{
    if ( o == Qt::Horizontal )
	return QMIN( maxsize, QMAX( w->sizeHint().width(), w->fixedExtent().width() ) );
    else
	return QMIN( maxsize, QMAX( w->sizeHint().height(), w->fixedExtent().height() ) );
}
示例#4
0
void Spacer::paintEvent( QPaintEvent * )
{
    QPainter p( this );
    p.setPen( Qt::blue );

    if ( orient == Horizontal ) {
	const int dist = 3;
	const int amplitude = QMIN( 3, height() / 3 );
	const int base = height() / 2;
	int i = 0;
	p.setPen( white );
	for ( i = 0; i < width() / 3 +2; ++i )
	    p.drawLine( i * dist, base - amplitude, i * dist + dist / 2, base + amplitude );
	p.setPen( blue );
	for ( i = 0; i < width() / 3 +2; ++i )
	    p.drawLine( i * dist + dist / 2, base + amplitude, i * dist + dist, base - amplitude );
	p.drawLine( 0, 0, 0, height() );
	p.drawLine( width() - 1, 0, width() - 1, height());
    } else {
	const int dist = 3;
	const int amplitude = QMIN( 3, width() / 3 );
	const int base = width() / 2;
	int i = 0;
	p.setPen( white );
	for ( i = 0; i < height() / 3 +2; ++i )
	    p.drawLine( base - amplitude, i * dist, base + amplitude,i * dist + dist / 2 );
	p.setPen( blue );
	for ( i = 0; i < height() / 3 +2; ++i )
	    p.drawLine( base + amplitude, i * dist + dist / 2, base - amplitude, i * dist + dist );
	p.drawLine( 0, 0, width(), 0 );
	p.drawLine( 0, height() - 1, width(), height() - 1 );
    }
}
示例#5
0
void Store::dumpBlock(portable_off_t s,portable_off_t e)
{
  portable_fseek(m_file,s,SEEK_SET);
  int size = (int)(e-s);
  uchar *buf = new uchar[size];
  if (fread(buf,size,1,m_file)==(size_t)size)
  {
    int i,j;
    for (i=0;i<size;i+=16)
    {
      printf("%08x: ",(int)s+i);
      for (j=i;j<QMIN(size,i+16);j++)
      {
        printf("%02x ",buf[i+j]);
      }
      printf("  ");
      for (j=i;j<QMIN(size,i+16);j++)
      {
        printf("%c",(buf[i+j]>=32 && buf[i+j]<128)?buf[i+j]:'.');
      }
      printf("\n");
    }
  }
  delete[] buf;
  portable_fseek(m_file,m_cur,SEEK_SET);
}
示例#6
0
/*!
  Sets the geometry of this item's widget to be contained within \a r,
  taking alignment and maximum size into account.
*/
void QWidgetItem::setGeometry( const QRect &r )
{
    QSize s = r.size().boundedTo( smartMaxSize( wid ) );
    int x = r.x();
    int y = r.y();
    if ( align & (HorAlign|VerAlign) ) {
	QSize pref = wid->sizeHint().expandedTo( wid->minimumSize() ); //###
	if ( align & HorAlign )
	    s.setWidth( QMIN( s.width(), pref.width() ) );
	if ( align & VerAlign ) {
	    if ( hasHeightForWidth() )
		s.setHeight( QMIN( s.height(), heightForWidth(s.width()) ) );
	    else
		s.setHeight( QMIN( s.height(), pref.height() ) );
	}
    }
    if ( align & Qt::AlignRight )
	x = x + ( r.width() - s.width() );
    else if ( !(align & Qt::AlignLeft) )
	x = x + ( r.width() - s.width() ) / 2;

    if ( align & Qt::AlignBottom )
	y = y + ( r.height() - s.height() );
    else if ( !(align & Qt::AlignTop) )
	y = y + ( r.height() - s.height() ) / 2;

    if ( !wid->isHidden() && !wid->isTopLevel() )
	wid->setGeometry( x, y, s.width(), s.height() );
}
double LineMarker::dist(int x, int y)
{
const QwtScaleMap &xMap = d_plot->canvasMap(xAxis());
const QwtScaleMap &yMap = d_plot->canvasMap(yAxis());

const int x0 = xMap.transform(d_rect.left());
const int y0 = yMap.transform(d_rect.top());
const int x1 = xMap.transform(d_rect.right());
const int y1 = yMap.transform(d_rect.bottom());

int xmin=QMIN(x0,x1);
int xmax=QMAX(x0,x1);
int ymin=QMIN(y0,y1);
int ymax=QMAX(y0,y1);
	
if ( (x>xmax || x<xmin || xmin==xmax) && (ymax<y || ymin>y || ymin==ymax))
	//return the shortest distance to one of the ends
	return QMIN(sqrt(double((x-x0)*(x-x0)+(y-y0)*(y-y0))),
				sqrt(double((x-x1)*(x-x1)+(y-y1)*(y-y1))));
	
double d;
if (x0==x1)
	d=abs(x-x0);
else
	{
	double a=(double)(y1-y0)/(double)(x1-x0);
	double b=y0-a*x0;
	d=(a*x-y+b)/sqrt(a*a+1);
	}	
return fabs(d);
}
示例#8
0
void QWidget::setMaximumSize( int maxw, int maxh )
{
#if defined(QT_CHECK_RANGE)
    if ( maxw > QWIDGETSIZE_MAX || maxh > QWIDGETSIZE_MAX ) {
	qWarning("QWidget::setMaximumSize: (%s/%s) "
		"The largest allowed size is (%d,%d)",
		 name( "unnamed" ), className(), QWIDGETSIZE_MAX,
		QWIDGETSIZE_MAX );
	maxw = QMIN( maxw, QWIDGETSIZE_MAX );
	maxh = QMIN( maxh, QWIDGETSIZE_MAX );
    }
    if ( maxw < 0 || maxh < 0 ) {
	qWarning("QWidget::setMaximumSize: (%s/%s) Negative sizes (%d,%d) "
		"are not possible",
		name( "unnamed" ), className(), maxw, maxh );
	maxw = QMAX( maxw, 0 );
	maxh = QMAX( maxh, 0 );
    }
#endif
    createExtra();
    if ( extra->maxw == maxw && extra->maxh == maxh )
	return;
    extra->maxw = maxw;
    extra->maxh = maxh;
    if ( maxw < width() || maxh < height() )
	resize( QMIN(maxw,width()), QMIN(maxh,height()) );
    if ( testWFlags(WType_TopLevel) ) {
	// XXX
    }
    updateGeometry();
}
示例#9
0
void QLineEdit::end( bool mark )
{
    int tlen = strlen( tbuf );
    if ( cursorPos != tlen || (!mark && hasMarkedText()) ) {
	int mo = showLastPartOffset( &tbuf[offset], fontMetrics(),
				     width() - (frame() ? 8 : 4) );
	int markStart = cursorPos;
	cursorPos = tlen;
	cursorOn = FALSE;
	blinkSlot();
	if ( mark ) {
	    markStart = QMIN( markStart, markDrag );
	    newMark( cursorPos );
	} else {
	    markStart = QMIN( markStart, minMark() );
	    markAnchor = markDrag = cursorPos;
	}
	d->pmDirty = TRUE;
	if ( mo > 0 ) {
	    offset += mo;
	    repaint( FALSE );
	} else {
	    repaintArea( markStart, tlen );
	}
    }
}
示例#10
0
void MineField::setCellSize( int cellsize )
{
    int b = 2;

    int w2 = cellsize*numCols;
    int h2 = cellsize*numRows;

    int w = QMIN( availableRect.width(), w2+b );
    int h = QMIN( availableRect.height(), h2+b );

    //
    // Don't rely on the change in cellsize to force a resize,
    // as it's possible to have the same size cells when going
    // from a large play area to a small one.
    //
    resizeContents(w2, h2);

    if ( availableRect.height() < h2 &&
	 availableRect.width() - w > style().scrollBarExtent().width() ) {
	w += style().scrollBarExtent().width();
    }

    setGeometry( availableRect.x() + (availableRect.width()-w)/2,
	    availableRect.y() + (availableRect.height()-h)/2, w, h );
    cellSize = cellsize;
}
示例#11
0
static void place_line( QValueList<DockData> &lastLine, Qt::Orientation o, int linestrut, int fullextent, int tbstrut, int maxsize, QDockAreaLayout * )
{
    QDockWindow *last = 0;
    QRect lastRect;
    for ( QValueList<DockData>::Iterator it = lastLine.begin(); it != lastLine.end(); ++it ) {
	if ( tbstrut != -1 && ::qt_cast<QToolBar*>((*it).w) )
	    (*it).rect.setHeight( tbstrut );
	if ( !last ) {
	    last = (*it).w;
	    lastRect = (*it).rect;
	    continue;
	}
	if ( !last->isStretchable() ) {
	    int w = QMIN( lastRect.width(), maxsize );
	    set_geometry( last, lastRect.x(), lastRect.y(), w, lastRect.height(), o );
	} else {
	    int w = QMIN( (*it).rect.x() - lastRect.x(), maxsize );
	    set_geometry( last, lastRect.x(), lastRect.y(), w,
			  last->isResizeEnabled() ? linestrut : lastRect.height(), o );
	}
	last = (*it).w;
	lastRect = (*it).rect;
    }
    if ( !last )
	return;
    if ( !last->isStretchable() ) {
	int w = QMIN( lastRect.width(), maxsize );
	set_geometry( last, lastRect.x(), lastRect.y(), w, lastRect.height(), o );
    } else {
	int w = QMIN( fullextent - lastRect.x() - ( o == Qt::Vertical ? 1 : 0 ), maxsize );
	set_geometry( last, lastRect.x(), lastRect.y(), w,
		      last->isResizeEnabled() ? linestrut : lastRect.height(), o );
    }
}
示例#12
0
void k9MenuEditor::resizeEvent ( QResizeEvent * e ) {
    QWMatrix m;
    double scalex=(e->size().width()-4.0)/720.0;
    double scaley=(e->size().height()-4.0)/576.0;
    m.scale(QMIN(scalex,scaley),QMIN(scalex,scaley));
    this->setWorldMatrix(m);

}
示例#13
0
void FillTool::setInterpolatedPixel(int x, int y)
{
    int fillRed = QMIN(QMAX(qRed(m_fillRgb) + qRed(m_image.pixel(x, y)) - qRed(m_oldRgb), 0), 255);
    int fillGreen = QMIN(QMAX(qGreen(m_fillRgb) + qGreen(m_image.pixel(x, y)) - qGreen(m_oldRgb), 0), 255);
    int fillBlue = QMIN(QMAX(qBlue(m_fillRgb) + qBlue(m_image.pixel(x, y)) - qBlue(m_oldRgb), 0), 255);

    m_image.setPixel(x, y, qRgb(fillRed, fillGreen, fillBlue));
}
示例#14
0
QRect QRect::operator&( const QRect &r ) const
{
    QRect tmp;
    tmp.x1 = QMAX( x1, r.x1 );
    tmp.x2 = QMIN( x2, r.x2 );
    tmp.y1 = QMAX( y1, r.y1 );
    tmp.y2 = QMIN( y2, r.y2 );
    return tmp;
}
示例#15
0
void Interface::DisegnaRect( QPoint topLeft ,  QPoint bottomRight )
{
                 Top_startX = QMIN(topLeft.x(), bottomRight.x());
                 Top_startY = QMIN(topLeft.y(), bottomRight.y()) ;
      
                 int Bot_endX = QMAX(topLeft.x(), bottomRight.x());
                 int Bot_endY = QMAX(topLeft.y(), bottomRight.y());
    
    
      QPoint topLefta( Top_startX , Top_startY );
      QPoint bottomRighta( Bot_endX , Bot_endY );  
      QRect areaplace( topLefta, bottomRighta );
    
      /*
      
      */
    
                TagliaPoi = areaplace;
                
                 /////////////////qDebug() << "####### TagliaPoi.width()  " << TagliaPoi.height(); 
    
                if (areaplace.width() > 9 ) {
                TagliaPoi = areaplace;
                QPen pen;
                pen.setStyle( Qt::SolidLine );
                    
                pen.setWidth( 2 );
                if (ratio > 80 && ratio < 110) {                    
                pen.setWidth( 2 );
                } 
                if (ratio < 81) {
                pen.setWidth( 4 ); 
                }
                if (ratio < 50) {
                pen.setWidth( 6 ); 
                }
                if (ratio > 130) {
                pen.setWidth( 1 ); 
                }
           
                pen.setColor( color1 );
                QPixmap nuovo(original2.width(),original2.height());
                QPainter painter;
                painter.begin(&nuovo); 
                painter.setRenderHint(QPainter::Antialiasing);
                painter.drawPixmap(0,0,original2);
                painter.setPen( pen);    /* penna */
                painter.drawRect(areaplace);  /* disegna */
                painter.end();  
                display = nuovo;
                int newlarge = (original2.width()/cento)*ratio;
                wrapper->paint(QPixmap(display.scaledToWidth(newlarge,Qt::FastTransformation)));
                setCursor(Qt::CrossCursor);
                UpdateNow();
                }
}
示例#16
0
QRect KstTopLevelView::newSizeCentered(const QRect& oldSize, const QRect& bounds, const QPoint& pos, bool maintainAspect) {
  QPoint npos = pos;

  npos.setX(QMAX(npos.x(), bounds.left()));
  npos.setX(QMIN(npos.x(), bounds.right()));
  npos.setY(QMIN(npos.y(), bounds.bottom()));
  npos.setY(QMAX(npos.y(), bounds.top()));

  return KstGfxMouseHandlerUtils::resizeRectFromCornerCentered(oldSize, npos, bounds, maintainAspect);
}
示例#17
0
int MineField::findCellSize()
{
    int w = availableRect.width() - 2;
    int h = availableRect.height() - 2;
    int cellsize;

    cellsize = QMIN( w/numCols, h/numRows );
    cellsize = QMIN( QMAX( cellsize, minGrid ), maxGrid );
    return cellsize;
}
示例#18
0
QwtDoubleRect Matrix::boundingRect()
{
    int rows = numRows();
    int cols = numCols();
    double dx = fabs(x_end - x_start)/(double)(cols - 1);
    double dy = fabs(y_end - y_start)/(double)(rows - 1);

    return QwtDoubleRect(QMIN(x_start, x_end) - 0.5*dx, QMIN(y_start, y_end) - 0.5*dy,
						 fabs(x_end - x_start) + dx, fabs(y_end - y_start) + dy).normalized();
}
示例#19
0
void KstTopLevelView::pressMoveLayoutModeEndPoint(const QPoint& pos, bool maintainAspect) {
  // FIXME: remove this!!  Should not know about any specific type
  // for now we only know how to deal with lines 

  QRect bounds = _pressTarget->_parent->geometry();
  QPoint npos = pos;

  //pos must be inside the parent
  npos.setX(QMAX(npos.x(), bounds.left()));
  npos.setX(QMIN(npos.x(), bounds.right()));
  npos.setY(QMIN(npos.y(), bounds.bottom()));
  npos.setY(QMAX(npos.y(), bounds.top()));

  if (KstViewLinePtr line = kst_cast<KstViewLine>(_pressTarget)) {
    QPoint movePoint, anchorPoint;
    QPoint *fromPoint, *toPoint;

    if (_pressDirection & UP) {
      // UP means we are on the start endpoint
      movePoint = line->from();
      anchorPoint = line->to();
      fromPoint = &movePoint;
      toPoint = &anchorPoint;
    } else { // (_pressDirection & DOWN)
      // DOWN means we are on the end endpoint
      movePoint = line->to();
      anchorPoint = line->from();
      fromPoint = &anchorPoint;
      toPoint = &movePoint;
    }

    if (maintainAspect) {
      movePoint = KstGfxMouseHandlerUtils::findNearestPtOnLine(anchorPoint, movePoint, npos, bounds);
    } else {
      movePoint = npos; // already enforced pos inside parent.
    }

    const QRect old(_prevBand);
    
    _prevBand.setTopLeft(*fromPoint);
    _prevBand.setBottomRight(*toPoint);

    if (old != _prevBand) {
      KstPainter p;
      p.begin(_w);
      p.setPen(QPen(Qt::black, 0, Qt::DotLine));
      p.setRasterOp(Qt::NotROP);
      if (old.topLeft() != QPoint(-1, -1)) {
        p.drawLine(old.topLeft(), old.bottomRight());
      } 
      p.drawLine(_prevBand.topLeft(), _prevBand.bottomRight());
      p.end();
    }
  }
}
示例#20
0
void QLineEdit::setSelection( int start, int length )
{
    int b, e;
    b = QMIN( markAnchor, markDrag );
    e = QMAX( markAnchor, markDrag );
    b = QMIN( b, start );
    e = QMAX( e, start + length );
    markAnchor = start;
    markDrag = start + length;
    repaintArea( b, e );
}
示例#21
0
QPoint SubWindow::forceInside( const QRect &enclosure, const QRect &prisoner )
{
    int new_x, new_y;

    new_x = QMIN( enclosure.right(), prisoner.right() ) - prisoner.width() + 1;
    new_x = QMAX( enclosure.left(), new_x );
    new_y = QMIN( enclosure.bottom(), prisoner.bottom() ) - prisoner.height() + 1;
    new_y = QMAX( enclosure.top(), new_y );

    return QPoint( new_x, new_y );
}
示例#22
0
void Matrix::initTable(int rows, int cols)
{
    initGlobals();
	d_view_type = TableView;

    d_matrix_model = new MatrixModel(rows, cols, this);
    initTableView();

	// resize the table
	setGeometry(50, 50, QMIN(_Matrix_initial_columns_, cols)*d_table_view->horizontalHeader()->sectionSize(0) + 55,
                (QMIN(_Matrix_initial_rows_,rows)+1)*d_table_view->verticalHeader()->sectionSize(0));
}
// private slot
void kpMainWindow::slotFitToPage ()
{
    if (!m_scrollView || !m_document)
        return;

    // doc_width * zoom / 100 <= view_width &&
    // doc_height * zoom / 100 <= view_height &&
    // 1 <= zoom <= 3200

    zoomTo (QMIN (3200, QMAX (1, QMIN (m_scrollView->visibleWidth () * 100 / m_document->width (),
                              m_scrollView->visibleHeight () * 100 / m_document->height ()))));
}
示例#24
0
void DrawView::mouseReleaseEvent( QMouseEvent *e )
  {
  int this_button;
  int my_left, my_right, my_top, my_bottom;

  this_button = e->button() & MouseButtonMask;

  switch ( this_button )
    {
    case LeftButton:
         if ( my_button == LeftButton )
           {
           point_2 = e->pos();
           my_left = QMIN( point_1.x(), point_2.x() );
           my_right = QMAX( point_1.x(), point_2.x() );
           my_top = QMIN( point_1.y(), point_2.y() );
           my_bottom = QMAX( point_1.y(), point_2.y() );
           if ( ( my_top != my_bottom ) && ( my_left != my_right ) )
             {
             center_x = center_x - my_width / 2.0 +
                        fract_ratio * my_left +
                        ( fract_ratio * ( my_right - my_left ) ) / 2.0;
             center_y = center_y - my_height / 2.0 +
                        fract_ratio * ( my_top - KFRACT_SIZE_DIFF_TOP ) +
                        ( fract_ratio * ( my_bottom - my_top ) ) / 2.0;
             my_width = ( my_width * ( my_right - my_left ) ) / width();
             my_height = ( my_width * ( height() - KFRACT_SIZE_DIFF_TOP ) ) / 
                                                                     width();
             fract_ratio = my_width / width();
             drawbuffer->fill( black );
             drawCheck();
             }
           else
             {
             bitBlt( this, my_left, my_top,
                     drawbuffer, my_left, my_top, my_right - my_left + 1,
                                                  my_bottom - my_top + 1,
                     CopyROP, FALSE );
             }
           }
         my_button = NoButton;
         break;
    case MidButton:
         my_button &= ~MidButton;
         break;
    case RightButton:
         my_button &= ~RightButton;
         break;
    default:
         break;
    }
  }
示例#25
0
bool KDialog::avoidArea( QWidget *w, const QRect& area, int screen )
{
  if ( !w )
    return false;
  QRect fg = w->frameGeometry();
  if ( !fg.intersects( area ) )
    return true; // nothing to do.

  QRect scr = screenRect( w, screen );
  QRect avoid( area ); // let's add some margin
  avoid.moveBy( -5, -5 );
  avoid.rRight() += 10;
  avoid.rBottom() += 10;

  if ( QMAX( fg.top(), avoid.top() ) <= QMIN( fg.bottom(), avoid.bottom() ) )
  {
    // We need to move the widget up or down
    int spaceAbove = QMAX(0, avoid.top() - scr.top());
    int spaceBelow = QMAX(0, scr.bottom() - avoid.bottom());
    if ( spaceAbove > spaceBelow ) // where's the biggest side?
      if ( fg.height() <= spaceAbove ) // big enough?
        fg.setY( avoid.top() - fg.height() );
      else
        return false;
    else
      if ( fg.height() <= spaceBelow ) // big enough?
        fg.setY( avoid.bottom() );
      else
        return false;
  }

  if ( QMAX( fg.left(), avoid.left() ) <= QMIN( fg.right(), avoid.right() ) )
  {
    // We need to move the widget left or right
    int spaceLeft = QMAX(0, avoid.left() - scr.left());
    int spaceRight = QMAX(0, scr.right() - avoid.right());
    if ( spaceLeft > spaceRight ) // where's the biggest side?
      if ( fg.width() <= spaceLeft ) // big enough?
        fg.setX( avoid.left() - fg.width() );
      else
        return false;
    else
      if ( fg.width() <= spaceRight ) // big enough?
        fg.setX( avoid.right() );
      else
        return false;
  }
  //kdDebug() << "Moving window to " << fg.x() << "," << fg.y() << endl;
  w->move(fg.x(), fg.y());
  return true;
}
void QGIFFormat::disposePrevious( QImage& img, QImageConsumer* consumer )
{
    if ( out_of_bounds ) // flush anything that survived
	consumer->changed(QRect(0,0,swidth,sheight));

    // Handle disposal of previous image before processing next one

    if ( disposed ) return;

    int l = QMIN(swidth-1,left);
    int r = QMIN(swidth-1,right);
    int t = QMIN(sheight-1,top);
    int b = QMIN(sheight-1,bottom);

    switch (disposal) {
      case NoDisposal:
	break;
      case DoNotChange:
	break;
      case RestoreBackground:
	if (trans_index>=0) {
	    // Easy:  we use the transparent color
	    fillRect(img, l, t, r-l+1, b-t+1, Q_TRANSPARENT);
	} else if (bgcol>=0) {
	    // Easy:  we use the bgcol given
	    fillRect(img, l, t, r-l+1, b-t+1, color(bgcol));
	} else {
	    // Impossible:  We don't know of a bgcol - use pixel 0
	    QRgb** line = (QRgb **)img.jumpTable();
	    fillRect(img, l, t, r-l+1, b-t+1, line[0][0]);
	}
	if (consumer)
	    consumer->changed(QRect(l, t, r-l+1, b-t+1));
	break;
      case RestoreImage: {
	if ( frame > 0 ) {
	    QRgb** line = (QRgb **)img.jumpTable();
	    for (int ln=t; ln<=b; ln++) {
		memcpy(line[ln]+l,
		    backingstore.scanLine(ln-t),
		    (r-l+1)*sizeof(QRgb) );
	    }
	    consumer->changed(QRect(l, t, r-l+1, b-t+1));
	}
      }
    }
    disposal = NoDisposal; // Until an extension says otherwise.

    disposed = TRUE;
}
示例#27
0
/* \internal
   Aquire ownership of the shared double buffer pixmap, subject to the
   following conditions:

   \list 1
   \i double buffering is enabled globally.
   \i the shared double buffer pixmap is not in use.
   \i the size specified in begin() is valid, and within limits.
   \endlist

   If all of these conditions are met, then this QSharedDoubleBuffer
   object becomes the owner of the shared double buffer pixmap.  The
   shared double buffer pixmap is resize if necessary, and this
   function returns a pointer to the pixmap.  Ownership must later be
   relinquished by calling releasePixmap().

   If none of the above conditions are met, this function returns
   zero.

   \sa releasePixmap()
*/
QPixmap *QSharedDoubleBuffer::getPixmap()
{
    if ( isDisabled() ) {
	// double buffering disabled globally
	return 0;
    }

    if ( qdb_owner ) {
	// shared pixmap already in use
	return 0;
    }

    if ( rw <= 0 || rh <= 0 ||
	 ( hardLimitWidth > 0 && rw >= hardLimitWidth ) ||
	 ( hardLimitHeight > 0 && rh >= hardLimitHeight ) ) {
	// invalid size, or hard limit reached
	return 0;
    }

    if ( rw >= sharedLimitWidth || rh >= sharedLimitHeight ) {
	if ( flags & Force ) {
	    rw = QMIN(rw, 8000);
	    rh = QMIN(rh, 8000);
	    // need to create a big pixmap and start the cleaner
	    if ( ! qdb_force_pixmap ) {
		qdb_force_pixmap = new QPixmap( rw, rh );
		qdb_pixmap_cleanup.add( &qdb_force_pixmap );
	    } else if ( qdb_force_pixmap->width () < rw ||
			qdb_force_pixmap->height() < rh ) {
		qdb_force_pixmap->resize( rw, rh );
	    }
	    qdb_owner = this;
	    staticCleaner()->start();
	    return qdb_force_pixmap;
	}

	// size is outside shared limit
	return 0;
    }

    if ( ! qdb_shared_pixmap ) {
	qdb_shared_pixmap = new QPixmap( rw, rh );
	qdb_pixmap_cleanup.add( &qdb_shared_pixmap );
    } else if ( qdb_shared_pixmap->width() < rw ||
		qdb_shared_pixmap->height() < rh ) {
	qdb_shared_pixmap->resize( rw, rh );
    }
    qdb_owner = this;
    return qdb_shared_pixmap;
}
示例#28
0
void KVocTrainTable::keyPressEvent(QKeyEvent * e)
{
  delayTimer->stop();
  switch(e->key())
  {
    case Key_Right: {
      int topCell = rowAt(0);
      int lastRowVisible = QMIN(numRows(), rowAt(contentsHeight()));
      if (numCols() > 2)
        for (int i = topCell; i <= lastRowVisible; i++)
          updateCell(i, KV_COL_ORG);
    }  // fallthrough
    case Key_Up:
    case Key_Down:
    case Key_Next:
    case Key_Prior:
      QTable::keyPressEvent(e);
      break;

      case Key_Left: {
        QTable::keyPressEvent(e);
        int topCell = rowAt(0);
        int lastRowVisible = QMIN(numRows(), rowAt(contentsHeight()));
        if (numCols() > 2)
          for (int i = topCell; i <= lastRowVisible; i++)
            updateCell(i, KV_COL_ORG);
      }
      break;

    case Key_Shift:
    case Key_Alt:
      case Key_Control:  // fallthrough
        QTable::keyPressEvent(e);
        emit forwardKeyPressEvent(e);
        break;

    case Key_Minus:
    case Key_Plus:
    case Key_Tab:
      case Key_Backtab:  // fallthrough
        emit forwardKeyPressEvent(e);
        break;

    default:
      QTable::keyPressEvent(e);
      break;
  }
}
QwtDoubleRect QwtErrorPlotCurve::boundingRect() const
{
	QwtDoubleRect rect = QwtPlotCurve::boundingRect();

	int size = dataSize();

	QwtArray <double> X(size), Y(size), min(size), max(size);
	for (int i=0; i<size; i++)
	{
		X[i]=x(i);
		Y[i]=y(i);
		if (type == Vertical)
		{
			min[i] = y(i) - err[i];
			max[i] = y(i) + err[i];
		}
		else
		{
			min[i] = x(i) - err[i];
			max[i] = x(i) + err[i];
		}
	}

	QwtArrayData *erMin, *erMax;
	if (type == Vertical)
	{
		erMin=new QwtArrayData(X, min);
		erMax=new QwtArrayData(X, max);
	}
	else
	{
		erMin=new QwtArrayData(min, Y);
		erMax=new QwtArrayData(max, Y);
	}

	QwtDoubleRect minrect = erMin->boundingRect();
	QwtDoubleRect maxrect = erMax->boundingRect();

	rect.setTop(QMIN(minrect.top(), maxrect.top()));
	rect.setBottom(QMAX(minrect.bottom(), maxrect.bottom()));
	rect.setLeft(QMIN(minrect.left(), maxrect.left()));
	rect.setRight(QMAX(minrect.right(), maxrect.right()));

	delete erMin;
	delete erMax;

	return rect;
}
void PolynomFitDialog::changeDataRange()
{
	double start = graph->selectedXStartValue();
	double end = graph->selectedXEndValue();
	boxStart->setText(QString::number(QMIN(start, end), 'g', 15));
	boxEnd->setText(QString::number(QMAX(start, end), 'g', 15));
}