Ejemplo n.º 1
0
    Symbol match(PcaContext& ctx, const TSomeView& imgv) const
    {
        boost::gil::gil_function_requires<boost::gil::ImageViewConcept<TSomeView> >();
        boost::gil::gil_function_requires<boost::gil::ColorSpacesCompatibleConcept<
                                    typename boost::gil::color_space_type<TSomeView>::type,
                                    typename boost::gil::color_space_type<ConstViewT>::type> >();
        boost::gil::gil_function_requires<boost::gil::ChannelsCompatibleConcept<
                                    typename boost::gil::channel_type<TSomeView>::type,
                                    typename boost::gil::channel_type<ConstViewT>::type> >();

        assert(static_cast<size_t>(imgv.width()) <= cellWidth());
        assert(static_cast<size_t>(imgv.height()) <= cellHeight());

        typedef boost::gil::layout<
                typename boost::gil::color_space_type<ConstViewT>::type,
                typename boost::gil::channel_mapping_type<TSomeView>::type
                > LayoutT;
        typedef typename float_channel_type<typename boost::gil::channel_type<ConstViewT>::type>::type FloatChannelT;
        typedef typename boost::gil::pixel_value_type<FloatChannelT, LayoutT>::type FloatPixelT;
        typedef typename boost::gil::type_from_x_iterator<FloatPixelT*>::view_t FloatViewT;

        FloatViewT tmp_glyph_view = boost::gil::interleaved_view(
                cellWidth(), cellHeight(),
                reinterpret_cast<FloatPixelT*>(ctx.imageData_.data()),
                cellWidth() * sizeof(FloatPixelT));

        boost::gil::fill_pixels(tmp_glyph_view, FloatPixelT());
        boost::gil::copy_and_convert_pixels(imgv, subimage_view(
                tmp_glyph_view, 0, 0, imgv.width(), imgv.height()));

        features()->project(ctx.imageData_, ctx.components_);
        return font()->getSymbol(features()->findClosestGlyph(ctx.components_));
    }
Ejemplo n.º 2
0
void KColorCells::paintCell( TQPainter *painter, int row, int col )
{
	TQBrush brush;
        int w = 1;

	if (shade)
        {
		qDrawShadePanel( painter, 1, 1, cellWidth()-2,
		    cellHeight()-2, colorGroup(), true, 1, &brush );
		w = 2;
        }
        TQColor color = colors[ row * numCols() + col ];
        if (!color.isValid())
	{
		if (!shade) return;
		color = backgroundColor();
	}

	painter->setPen( color );
	painter->setBrush( TQBrush( color ) );
	painter->drawRect( w, w, cellWidth()-w*2, cellHeight()-w*2 );

	if ( row * numCols() + col == selected )
		painter->drawWinFocusRect( w, w, cellWidth()-w*2, cellHeight()-w*2 );
}
Ejemplo n.º 3
0
//==================================================================
void KCharSelectTable::setToolTips()
{
    const int rowCount = numRows();
    const int colCount = numCols();
    for( int i=0 ; i< rowCount; ++i )
    {
	for( int j=0; j< colCount; ++j )
	{
	    const QRect r( cellWidth()*j, cellHeight()*i, cellWidth(), cellHeight() );
	    QToolTip::remove(this,r);
	    const ushort uni = vTableNum * 256 + numCols()*i + j;
	    QString s;
	    s.sprintf( "%04X", uint( uni ) );
	    QString character; // Character (which sometimes need to be escaped)
            switch ( uni )
	    {
                case 0x3c: character = "&lt;"; break;
                case 0x3e: character = "&gt;"; break;
                case 0x26: character = "&amp;"; break;
                case 0x27: character = "&apos;"; break;
                case 0x22: character = "&quot;"; break;
                default: character = QChar( uni ); break;
	    }
	    QToolTip::add(this, r, i18n( "Character","<qt><font size=\"+4\" face=\"%1\">%2</font><br>Unicode code point: U+%3<br>(In decimal: %4)<br>(Character: %5)</qt>" ).arg( vFont ).arg( character ).arg( s ).arg( uni ).arg( character ) );
	}
    }
}
Ejemplo n.º 4
0
QRect TicTacToe::cellRect(int row, int column) const
{
    const int HMargin = width() / 30;
    const int VMargin = height() / 30;
    return QRect(column * cellWidth() + HMargin,
                 row * cellHeight() + VMargin,
                 cellWidth() - 2 * HMargin,
                 cellHeight() - 2 * VMargin);
}
Ejemplo n.º 5
0
void TicTacToe::paintEvent(QPaintEvent * /* event */)
{
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);

    painter.setPen(QPen(Qt::darkGreen, 1));
    painter.drawLine(cellWidth(), 0, cellWidth(), height());
    painter.drawLine(2 * cellWidth(), 0, 2 * cellWidth(), height());
    painter.drawLine(0, cellHeight(), width(), cellHeight());
    painter.drawLine(0, 2 * cellHeight(), width(), 2 * cellHeight());

    painter.setPen(QPen(Qt::darkBlue, 2));

    for (int position = 0; position < 9; ++position) {
        QRect cell = cellRect(position / 3, position % 3);

        if (myState.at(position) == Cross) {
            painter.drawLine(cell.topLeft(), cell.bottomRight());
            painter.drawLine(cell.topRight(), cell.bottomLeft());
        } else if (myState.at(position) == Nought) {
            painter.drawEllipse(cell);
        }
    }

    painter.setPen(QPen(Qt::yellow, 3));

    for (int position = 0; position < 9; position = position + 3) {
        if (myState.at(position) != Empty
                && myState.at(position + 1) == myState.at(position)
                && myState.at(position + 2) == myState.at(position)) {
            int y = cellRect((position / 3), 0).center().y();
            painter.drawLine(0, y, width(), y);
            turnNumber = 9;
        }
    }

    for (int position = 0; position < 3; ++position) {
        if (myState.at(position) != Empty
                && myState.at(position + 3) == myState.at(position)
                && myState.at(position + 6) == myState.at(position)) {
            int x = cellRect(0, position).center().x();
            painter.drawLine(x, 0, x, height());
            turnNumber = 9;
        }
    }
    if (myState.at(0) != Empty && myState.at(4) == myState.at(0)
            && myState.at(8) == myState.at(0)) {
        painter.drawLine(0, 0, width(), height());
        turnNumber = 9;
    }
    if (myState.at(2) != Empty && myState.at(4) == myState.at(2)
            && myState.at(6) == myState.at(2)) {
        painter.drawLine(0, height(), width(), 0);
        turnNumber = 9;
    }
}
Ejemplo n.º 6
0
void
KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col)
{
  int index;
  QString text;
  // ----- find the number of the cell:
  index=3*row+col+1;
  text=KGlobal::locale()->monthName(index, false);
  painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text);
  if ( activeCol == col && activeRow == row )
      painter->drawRect( 0, 0, cellWidth(), cellHeight() );
}
int SimpleTableViewDataSource::indexFromCumulatedWidth(KDCoordinate offsetX) {
  KDCoordinate width = cellWidth();
  if (width == 0) {
    return 0;
  }
  return (offsetX - 1) / width;
}
Ejemplo n.º 8
0
void PiecesTable::paintCell(QPainter *p, int row, int col)
{
  int w = cellWidth();
  int h = cellHeight();

  uint pos = col+row*numCols();

  /* sanity check. setNumRows()/setNumCols() calls repaint() directly */
  if ( pos >= _map.count() ) {
      p->drawRect(0, 0, w, h);
      return;
  }

  int number = _map[col + row * numCols()] + 1;

  // draw cell background
  if(number == numCols()*numRows() ) {
    p->setBrush(colorGroup().background());
    p->setPen(NoPen);
    p->drawRect(0, 0, w, h);
    return;
  }

  /* no tiles then contentRect() is not visible or too small anyway */
  if( _pixmap.count() == 0 )
      return;

  p->drawPixmap(0, 0, *(_pixmap[(number-1 )]) );
}
Ejemplo n.º 9
0
/** Calculates the rectangle in the character grid covered by a certain rectangle. */
QRect QTconsoleView::charsFromRect( int x, int y, int width, int height )
{
   int c1, c2, w, h;

   c1 = x / cellWidth();
   w = ( x + width) / cellWidth();
   if ( (x+width) % cellWidth() ) w++;
   c2 = ( y- TOP_MARGIN ) / cellHeight();
   h = (y+height - TOP_MARGIN ) / cellHeight();
   if ( (y+height - TOP_MARGIN ) % cellHeight() ) h++;

   if ( c1 < 0 ) c1 = 0;
   if ( c2 < 0 ) c2 = 0;
   if ( w > pDoc->cols() ) w = pDoc->cols();
   if ( h > pDoc->rows() ) h = pDoc->rows();
   return QRect( c1, c2, w-c1, h-c2 );
}
Ejemplo n.º 10
0
int KColorCells::posToCell(const TQPoint &pos, bool ignoreBorders)
{
   int row = pos.y() / cellHeight();
   int col = pos.x() / cellWidth();
   int cell = row * numCols() + col;

   if (!ignoreBorders)
   {
      int border = 2;
      int x = pos.x() - col * cellWidth();
      int y = pos.y() - row * cellHeight();
      if ( (x < border) || (x > cellWidth()-border) ||
           (y < border) || (y > cellHeight()-border))
         return -1;
   }
   return cell;
}
Ejemplo n.º 11
0
//==================================================================
QSize KCharSelectTable::sizeHint() const
{
    int w = cellWidth();
    int h = cellHeight();

    w *= numCols();
    h *= numRows();

    return QSize( w, h );
}
Ejemplo n.º 12
0
//==================================================================
void KCharSelectTable::paintCell( class QPainter* p, int row, int col )
{
    const int w = cellWidth();
    const int h = cellHeight();
    const int x2 = w - 1;
    const int y2 = h - 1;

    //if( row == 0 && col == 0 ) {
    //    printf("Repaint %d\n", temp++);
    //    fflush( stdout );
    //    }

    QFont font = QFont( vFont );
    font.setPixelSize( int(.7 * h) );

    unsigned short c = vTableNum * 256;
    c += row * numCols();
    c += col;

    if ( c == vChr.unicode() ) {
	p->setBrush( QBrush( colorGroup().highlight() ) );
	p->setPen( NoPen );
	p->drawRect( 0, 0, w, h );
	p->setPen( colorGroup().highlightedText() );
	vPos = QPoint( col, row );
    } else {
	QFontMetrics fm = QFontMetrics( font );
	if( fm.inFont( c ) )
		p->setBrush( QBrush( colorGroup().base() ) );
	else
		p->setBrush( QBrush( colorGroup().button() ) );
	p->setPen( NoPen );
	p->drawRect( 0, 0, w, h );
	p->setPen( colorGroup().text() );
    }

    if ( c == focusItem.unicode() && hasFocus() ) {
	style().drawPrimitive( QStyle::PE_FocusRect, p, QRect( 2, 2, w - 4, h - 4 ), 
			       colorGroup() );
	focusPos = QPoint( col, row );
    }

    p->setFont( font );

    p->drawText( 0, 0, x2, y2, AlignHCenter | AlignVCenter, QString( QChar( c ) ) );

    p->setPen( colorGroup().text() );
    p->drawLine( x2, 0, x2, y2 );
    p->drawLine( 0, y2, x2, y2 );

    if ( row == 0 )
	p->drawLine( 0, 0, x2, 0 );
    if ( col == 0 )
	p->drawLine( 0, 0, 0, y2 );
}
Ejemplo n.º 13
0
void CustomPalette::paintCell( QPainter *painter, int row, int col )
{
    QColor cell_color = color_matrix[row][col];

    if ( cell_color.isValid() )
    {
        if ( sel_row == row && sel_col == col )
	    painter -> setPen( Qt::white );
	else
            painter -> setPen( cell_border_color );
        painter -> setBrush( cell_color );
        painter -> drawRect( 0, 0, cellWidth(), cellHeight() );
    }
    else
    {
        painter -> setPen( Qt::white );
        painter -> setBrush( Qt::white );
        painter -> drawRect( 0, 0, cellWidth(), cellHeight() );
    }
}
Ejemplo n.º 14
0
//==================================================================
void KCharSelectTable::resizeEvent( QResizeEvent * e )
{
    const int new_w   = (e->size().width()  - 2*(margin()+frameWidth())) / numCols();
    const int new_h   = (e->size().height() - 2*(margin()+frameWidth())) / numRows();

    if( new_w !=  cellWidth())
        setCellWidth( new_w );
    if( new_h !=  cellHeight())
        setCellHeight( new_h );

    setToolTips();
}
Ejemplo n.º 15
0
int DiffView::cellWidth(int col)
{
    if (col == 0 && linenos)
    {
        QFontMetrics fm(font());
        return fm.width("10000");
    }
    else if (marker && (col == 0 || col == 1))
    {
        QFontMetrics fm( fontMetrics() );
        return qMax(qMax( fm.width(i18n("Delete")),
                          fm.width(i18n("Insert"))),
                    fm.width(i18n("Change")))+2*BORDER;
    }
    else
    {
        int rest = (linenos || marker)? cellWidth(0) : 0;
        if (linenos && marker)
            rest += cellWidth(1);
        return qMax(textwidth, viewWidth()-rest);
    }
}
Ejemplo n.º 16
0
void QWellArray::paintEvent(QPaintEvent *e)
{
    QRect r = e->rect();
    int cx = r.x();
    int cy = r.y();
    int ch = r.height();
    int cw = r.width();
    int colfirst = columnAt(cx);
    int collast = columnAt(cx + cw);
    int rowfirst = rowAt(cy);
    int rowlast = rowAt(cy + ch);

    if (isRightToLeft()) {
        int t = colfirst;
        colfirst = collast;
        collast = t;
    }

    QPainter painter(this);
    QPainter *p = &painter;
    QRect rect(0, 0, cellWidth(), cellHeight());

    if (collast < 0 || collast >= ncols)
        collast = ncols-1;
    if (rowlast < 0 || rowlast >= nrows)
        rowlast = nrows-1;

    // Go through the rows
    for (int r = rowfirst; r <= rowlast; ++r) {
        // get row position and height
        int rowp = rowY(r);

        // Go through the columns in the row r
        // if we know from where to where, go through [colfirst, collast],
        // else go through all of them
        for (int c = colfirst; c <= collast; ++c) {
            if (ncols*r+c >= ncells)
                return;

            // get position and width of column c
            int colp = columnX(c);
            // Translate painter and draw the cell
            rect.translate(colp, rowp);
            paintCell(p, r, c, rect);
            rect.translate(-colp, -rowp);
        }
    }
}
Ejemplo n.º 17
0
void KPopupMenu::paintCell(QPainter *p, int row, int col)
{
    if (row != 0)
        QPopupMenu::paintCell(p, row, col);
    else if ( ( (row == 0) && (col == 1) && (isCheckable()) ) || 
		( (row == 0) && (col == 0) && (!isCheckable()) ) ) {
        int cellh = cellHeight(0);
        int cellw = cellWidth(0);
        QColorGroup cg = this->colorGroup();
        
        p->setPen(cg.light());
		p->drawText(6, 3, cellw, cellh-4, 
			DontClip|AlignVCenter|ShowPrefix|SingleLine, text(0));
        p->setPen(cg.text());
		p->drawText(5, 2, cellw, cellh-4, 
			DontClip|AlignVCenter|ShowPrefix|SingleLine, text(0));
    }
}
Ejemplo n.º 18
0
VRFSystemMiniView::VRFSystemMiniView()
{
  m_length = 75;
  m_zones = 0;
  m_terminals = 0;

  m_vrfOutdoorPix = QPixmap(":images/vrf_outdoor.png").scaled(m_length,m_length);
  m_vrfTransferPix = QPixmap(":images/vrf_transfer.png").scaled(m_length,m_length);
  m_vrfTerminalPix = QPixmap(":images/vrf_unit.png").scaled(m_length,m_length);
  m_vrfZonePix = QPixmap(":images/zone.png").scaled(m_length,m_length);

  removeButtonItem = new RemoveButtonItem();
  removeButtonItem->setParentItem(this);
  removeButtonItem->setPos(cellWidth() - removeButtonItem->boundingRect().width() - 10,headerHeight() / 2.0 - removeButtonItem->boundingRect().height() / 2.0);

  zoomInButtonItem = new ZoomInButtonItem();
  zoomInButtonItem->setParentItem(this);
  zoomInButtonItem->setPos(removeButtonItem->pos().x() - 10 - zoomInButtonItem->boundingRect().width(),headerHeight() / 2.0 - zoomInButtonItem->boundingRect().height() / 2.0);
}
Ejemplo n.º 19
0
int Q3GridView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = Q3ScrollView::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    
#ifndef QT_NO_PROPERTIES
     if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< int*>(_v) = numRows(); break;
        case 1: *reinterpret_cast< int*>(_v) = numCols(); break;
        case 2: *reinterpret_cast< int*>(_v) = cellWidth(); break;
        case 3: *reinterpret_cast< int*>(_v) = cellHeight(); break;
        }
        _id -= 4;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setNumRows(*reinterpret_cast< int*>(_v)); break;
        case 1: setNumCols(*reinterpret_cast< int*>(_v)); break;
        case 2: setCellWidth(*reinterpret_cast< int*>(_v)); break;
        case 3: setCellHeight(*reinterpret_cast< int*>(_v)); break;
        }
        _id -= 4;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 4;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Ejemplo n.º 20
0
void PiecesTable::paintCell(TQPainter *p, int row, int col)
{
    int w = cellWidth();
    int h = cellHeight();
    int x2 = w - 1;
    int y2 = h - 1;

    int number = _map[col + row * numCols()] + 1;

    bool active = (row == _activeRow && col == _activeCol);

    // draw cell background
    if(number == 16)
        p->setBrush(colorGroup().background());
    else
        p->setBrush(_colors[number-1]);
    p->setPen(NoPen);
    p->drawRect(0, 0, w, h);

    // draw borders
    if (height() > 40) {
        p->setPen(colorGroup().text());
        if(col < numCols()-1)
            p->drawLine(x2, 0, x2, y2); // right border line

        if(row < numRows()-1)
            p->drawLine(0, y2, x2, y2); // bottom boder line
    }

    // draw number
    if (number == 16) return;
    if(active)
        p->setPen(white);
    else
        p->setPen(black);
    p->drawText(0, 0, x2, y2, AlignHCenter | AlignVCenter, TQString::number(number));
}
Ejemplo n.º 21
0
    void paintCell( QPainter *p, int row, int col ) {
	p->drawLine( cellWidth()-1, 0, cellWidth()-1, cellHeight()-1 );
	p->drawLine( 0, cellHeight()-1, cellWidth()-1, cellHeight()-1 );
	p->drawText( cellRect(), AlignCenter, QString("%1 / %1").arg(row).arg(col) );
    }
Ejemplo n.º 22
0
KDCoordinate SimpleTableViewDataSource::cumulatedWidthFromIndex(int i) {
  return cellWidth() * i;
}
Ejemplo n.º 23
0
void
KDateTable::paintCell(QPainter *painter, int row, int col)
{
  QRect rect;
  QString text;
  QPen pen;
  int w=cellWidth();
  int h=cellHeight();
  int pos;
  QBrush brushBlue(blue);
  QBrush brushLightblue(lightGray);
  QFont font=KGlobalSettings::generalFont();
  // -----
  font.setPointSize(fontsize);
  if(row==0)
    { // we are drawing the headline
      font.setBold(true);
      painter->setFont(font);
      bool normalday = true;
      QString daystr;
      if (KGlobal::locale()->weekStartsMonday())
        {
          daystr = KGlobal::locale()->weekDayName(col+1, true);
          if (col == 5 || col == 6)
              normalday = false;
        } else {
          daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true);
          if (col == 0 || col == 6)
              normalday = false;
        }
      if (!normalday)
        {
          painter->setPen(lightGray);
          painter->setBrush(brushLightblue);
          painter->drawRect(0, 0, w, h);
          painter->setPen(blue);
        } else {
          painter->setPen(blue);
          painter->setBrush(brushBlue);
          painter->drawRect(0, 0, w, h);
          painter->setPen(white);
        }
      painter->drawText(0, 0, w, h-1, AlignCenter,
                        daystr, -1, &rect);
      painter->setPen(black);
      painter->moveTo(0, h-1);
      painter->lineTo(w-1, h-1);
      // ----- draw the weekday:
    } else {
      painter->setFont(font);
      pos=7*(row-1)+col;
      if (KGlobal::locale()->weekStartsMonday())
          pos++;
      if(pos<firstday || (firstday+numdays<=pos))
        { // we are either
          // ° painting a day of the previous month or
          // ° painting a day of the following month
          if(pos<firstday)
            { // previous month
              text.setNum(numDaysPrevMonth+pos-firstday+1);
            } else { // following month
              text.setNum(pos-firstday-numdays+1);
            }
          painter->setPen(gray);
        } else { // paint a day of the current month
          text.setNum(pos-firstday+1);
          painter->setPen(black);
        }

      pen=painter->pen();
      if(firstday+date.day()-1==pos)
        {
          if(hasFocus())
            { // draw the currently selected date
              painter->setPen(red);
              painter->setBrush(darkRed);
              pen=white;
            } else {
              painter->setPen(darkGray);
              painter->setBrush(darkGray);
              pen=white;
            }
        } else {
          painter->setBrush(lightGray);
          painter->setPen(lightGray);
        }
      painter->drawRect(0, 0, w, h);
      painter->setPen(pen);
      painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect);
    }
  if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width());
  if(rect.height()>maxCell.height()) maxCell.setHeight(rect.height());
}
Ejemplo n.º 24
0
void MarkListTable::paintCell( QPainter *p, int row, int col)
{
	QColorGroup cg = QApplication::palette()->normal();
	
	if ( col == 0  )
	{
	
		if ( items.at( row )->select() )
			{
				//p->setBrush( selectColor );
				//p->setPen( selectColor );
				p->setBrush(cg.base());
				p->setPen(cg.base());
			}
		else {
			p->setBrush(cg.base());
				p->setPen(cg.base());
		}	
		p->drawRect(0,0,cellWidth(0),cellHeight());
		
		if( items.at( row )->mark() ) {
		
		int xOffset=6; int yOffset=3;
		
		if ( items.at( row )->select() )
			p->setPen( cg.text() ); //p->setPen( selectTextColor );
		else
			p->setPen( cg.text() );
		p->drawLine( xOffset+4, yOffset, xOffset+4, yOffset+9 );
		p->setPen( red );
		p->drawLine( xOffset+3, yOffset+1, xOffset, yOffset+4 );
		p->drawLine( xOffset+3, yOffset+1, xOffset+3, yOffset+4 );
		p->drawLine( xOffset, yOffset+4, xOffset+3, yOffset+4 );
		} else {
			int xOffset=4; int yOffset=5;
			
			p->setPen( cg.dark() );
			p->setBrush( cg.dark() );
			p->drawEllipse( xOffset+4, yOffset, 4, 4 );
			
			//p->setPen( cg.mid() );
			//p->setBrush( cg.mid() );
			//p->drawEllipse( xOffset+5, yOffset+1, 2, 2 );
			
			p->setPen( white );
			p->drawPoint( xOffset+5, yOffset+1);
		}	
	}

	/*if ( col == 1 )
	{
		if ( items.at( row )->select() )
		{
			p->setBrush(selectColor);
			p->setPen(selectColor);
			p->drawRect(0,0,cellWidth(1),cellHeight());
			
			//qDrawShadePanel( p, 3, 2, cellHeight( 1 ) - 6, cellHeight(1)-4,
			//	cg, FALSE, 1, &QBrush(colorGroup().light()));
			
			p->setBrush(white);
			p->setPen(black);	
			p->drawRect(3,2,cellHeight( 1 ) - 7, cellHeight(1)-5);
			
		} else {
			
			p->setBrush(cg.base());
				p->setPen(cg.base());
			p->drawRect(0,0,cellWidth(1),cellHeight());
			
			//qDrawShadePanel( p, 3, 2, cellHeight( 1 ) - 6, cellHeight(1)-4,
			//	cg, FALSE,1 );
				
			p->setBrush(white);
			p->setPen(black);	
			p->drawRect(3,2,cellHeight( 1 ) - 7, cellHeight(1)-5);
			
		}

		//QFontMetrics fm = p->fontMetrics();
		//int yPos;   // vertical text position
		//if ( 10 < fm.height() )
		//	yPos = fm.ascent() + fm.leading()/2;
		//else
		//	yPos = 5 - fm.height()/2 + fm.ascent();
		//p->drawText( 4, yPos, items.at( row )->text() );
	}*/
	
	if ( col == 1 )
	{
		if ( items.at( row )->select() )
			{
				p->setBrush(selectColor);
				p->setPen(selectColor);
			}
		else {
			p->setBrush(cg.base());
				p->setPen(cg.base());
		}	
		p->drawRect(0,0,cellWidth(2),cellHeight());
		
		
		/*  if ( items.at( row )->select() )
		{
			QColorGroup cg = QApplication::palette()->normal();
			qDrawShadePanel( p, 0, 0, cellWidth( 1 ) - 1, cellHeight(),
				cg, FALSE, 1, &QBrush(colorGroup().light()));
		}*/
		
		if ( items.at( row )->select() )
			p->setPen(selectTextColor);
		else
			p->setPen(cg.text());
		QFontMetrics fm = p->fontMetrics();
		int yPos;   // vertical text position
		/*if ( 10 < fm.height() )
			yPos = fm.ascent() + fm.leading()/2;
		else*/
			yPos = cellHeight()-fm.leading()/2;
			yPos = fm.ascent() + fm.leading()/2+1;
		p->drawText( 4, yPos, items.at( row )->text() );
	}
}
Ejemplo n.º 25
0
QRectF VRFSystemMiniView::headerRect() const
{
  return QRectF(0,0,cellWidth(),headerHeight());
}
Ejemplo n.º 26
0
QRectF VRFSystemMiniView::contentRect() const
{
  return QRectF(0,headerHeight(),cellWidth(),cellHeight());
}
Ejemplo n.º 27
0
QSize VRFSystemMiniView::cellSize()
{
  return QSize(cellWidth(),cellHeight() + headerHeight());
}
Ejemplo n.º 28
0
KDCoordinate SimpleTableViewDataSource::columnWidth(int i) {
  return cellWidth();
}
void KDReports::SpreadsheetReportLayout::paintPageContent(int pageNumber, QPainter &painter)
{
    //qDebug() << "painting with" << m_tableLayout.scaledFont();
    QAbstractItemModel* model = m_tableLayout.m_model;
    const qreal padding = m_tableLayout.scaledCellPadding();
    const QRect cellCoords = m_pageRects[pageNumber];
    //qDebug() << "painting page" << pageNumber << "cellCoords=" << cellCoords;
    qreal y = 0 /*m_topMargin*/; // in pixels
    const qreal rowHeight = m_tableLayout.rowHeight();

    if ( m_tableLayout.m_horizontalHeaderVisible ) {
        qreal x = 0 /*m_leftMargin*/;
        if ( m_tableLayout.m_verticalHeaderVisible ) {
            x += m_tableLayout.vHeaderWidth();
        }
        for ( int col = cellCoords.left(); col <= cellCoords.right(); ++col )
        {
            const QRectF cellRect( x, y, m_tableLayout.m_columnWidths[ col ], m_tableLayout.hHeaderHeight() );
            paintTableHorizontalHeader( cellRect, painter, col );
            x += cellRect.width();
        }
        y += m_tableLayout.hHeaderHeight();
    }

    const int firstRow = cellCoords.top();
    const int firstColumn = cellCoords.left();
    const int numRows = cellCoords.height();
    const int numColumns = cellCoords.width();

    // This won't work across page breaks....
    QVector<QBitArray> coveredCells;
    coveredCells.resize( numRows );
    for ( int row = firstRow; row <= cellCoords.bottom(); ++row )
        coveredCells[row - firstRow].resize( numColumns );

    for ( int row = firstRow; row <= cellCoords.bottom(); ++row )
    {
        qreal x = 0 /*m_leftMargin*/;
        if ( m_tableLayout.m_verticalHeaderVisible ) {
            x = paintTableVerticalHeader( x, y, painter, row );
        }
        painter.setFont( m_tableLayout.scaledFont() );
        for ( int col = cellCoords.left(); col <= cellCoords.right(); ++col )
        {
            if (coveredCells[row - firstRow].testBit(col - firstColumn)) {
                x += m_tableLayout.m_columnWidths[ col ];
                continue;
            }

            const QModelIndex index = model->index( row, col );

            const QSize span = model->span( index );
            if (span.isValid()) {
                for (int r = row; r < row + span.height() && r < numRows; ++r) {
                    for (int c = col; c < col + span.width() && c < numColumns; ++c) {
                        coveredCells[r - firstRow].setBit(c - firstColumn);
                    }
                }
            }

            const QRectF cellRect( x, y, cellWidth( col, span.width() ), qMax(1, span.height()) * rowHeight );
            const QRectF cellContentsRect = cellRect.adjusted( padding, padding, -padding, -padding );
            //qDebug() << "cell" << row << col << "rect=" << cellRect;

            const QString cellText = model->data( index, Qt::DisplayRole ).toString();
            const QColor foreground = qvariant_cast<QColor>( model->data( index, Qt::ForegroundRole ) );
            const QColor background = qvariant_cast<QColor>( model->data( index, Qt::BackgroundRole ) );
            const Qt::Alignment alignment( model->data( index, Qt::TextAlignmentRole ).toInt() );
            const QVariant decorationAlignment( model->data( index, KDReports::AutoTableElement::DecorationAlignmentRole ) );
            const QVariant cellDecoration( model->data( index, Qt::DecorationRole ) );

            if ( background.isValid() ) {
                painter.fillRect( cellRect, QBrush( background ) );
            } else if ( span.isValid() ) {
                painter.fillRect( cellRect, Qt::white );
            }
            drawBorder(cellRect, painter);

            // Per-cell font is not supported, on purpose. All rows use the same font,
            // otherwise the calculations for making things fit into a number of pages
            // become quite complex and slow.
            //const QVariant cellFont = model->data( index, Qt::FontRole );
            //if ( cellFont.isValid() )
            //    painter.setFont( qvariant_cast<QFont>( cellFont ) );
            //else
            //    painter.setFont( scaledFont );

            if ( foreground.isValid() )
                painter.setPen( foreground );

            paintTextAndIcon( painter, cellContentsRect, cellText, cellDecoration, decorationAlignment, alignment );

            if ( foreground.isValid() )
                painter.setPen( Qt::black );

            x += m_tableLayout.m_columnWidths[ col ];
        }
        y += rowHeight;
    }
}
Ejemplo n.º 30
0
void DiffView::paintCell(QPainter *p, int row, int col)
{
    QFontMetrics fm(font());

    DiffViewItem *item = items.at(row);

    int width = cellWidth(col);
    int height = cellHeight();

    QColor backgroundColor;
    bool inverted;
    Qt::Alignment align;
    int innerborder;
    QString str;

    QFont oldFont(p->font());
    if (item->type==Separator)
    {
        backgroundColor = KColorScheme(QPalette::Active, KColorScheme::Selection).background().color();
        p->setPen(KColorScheme(QPalette::Active, KColorScheme::Selection).foreground().color());
        inverted = false;
        align = Qt::AlignLeft;
        innerborder = 0;
        if (col == (linenos?1:0) + (marker?1:0))
            str = item->line;
        QFont f(oldFont);
        f.setBold(true);
        p->setFont(f);
    }
    else if (col == 0 && linenos)
    {
        backgroundColor = KColorScheme(QPalette::Active, KColorScheme::Selection).background().color();
        p->setPen(KColorScheme(QPalette::Active, KColorScheme::Selection).foreground().color());
        inverted = false;
        align = Qt::AlignLeft;
        innerborder = 0;
        if (item->no == -1)
            str = "+++++";
        else
            str.setNum(item->no);
    }
    else if (marker && (col == 0 || col == 1))
    {
        backgroundColor = KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::AlternateBackground).color();
        p->setPen(KColorScheme(QPalette::Active, KColorScheme::View).foreground().color());
        inverted = false;
        align = Qt::AlignRight;
        innerborder = BORDER;
        str = (item->type==Change)? i18n("Change")
            : (item->type==Insert)? i18n("Insert")
            : (item->type==Delete)? i18n("Delete") : QString();
    }
    else
    {
        backgroundColor =
            (item->type==Change)? diffChangeColor
            : (item->type==Insert)? diffInsertColor
            : (item->type==Delete)? diffDeleteColor
            : (item->type==Neutral)? KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::AlternateBackground).color() : KColorScheme(QPalette::Active, KColorScheme::View).background().color();
        p->setPen(KColorScheme(QPalette::Active, KColorScheme::View).foreground().color());
        inverted = item->inverted;
        align = Qt::AlignLeft;
        innerborder = 0;
        str = item->line;
    }

    if (inverted)
    {
        p->setPen(backgroundColor);
        backgroundColor = KColorScheme(QPalette::Active, KColorScheme::View).foreground().color();
        QFont f(oldFont);
        f.setBold(true);
        p->setFont(f);
    }

    p->fillRect(0, 0, width, height, backgroundColor);
    QTextOption textOption(align);
    textOption.setTabStop(m_tabWidth * fm.width(' '));
    p->drawText(QRectF(innerborder, 0, width-2*innerborder, height), str, textOption);
    p->setFont(oldFont);
}