Exemple #1
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 ) );
	}
    }
}
Exemple #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 );
}
Exemple #3
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_));
    }
Exemple #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);
}
Exemple #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;
    }
}
Exemple #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::indexFromCumulatedHeight(KDCoordinate offsetY) {
  KDCoordinate height = cellHeight();
  if (height == 0) {
    return 0;
  }
  return (offsetY - 1) / height;
}
Exemple #8
0
void MarkListTable::select( int i )
{
	if ( i < 0 || i >= (signed) items.count() || i == sel )
		return ;

	MarkListTableItem *it = items.at( i );
	if ( sel != -1 )
	{
		items.at( sel )->setSelect( FALSE );
		updateCell( sel, 0 );
		updateCell( sel, 1 );
		//updateCell( sel, 2 );
	}
	it->setSelect( TRUE );
	sel = i;
	updateCell( i, 0 );
	updateCell( i, 1 );
	//updateCell( i, 2 );
	emit selected( i );
	emit selected( it->text() );
	if ( ( i<=0 || rowIsVisible( i-1 ) ) &&
	     ( i>= (signed) items.count()-1 || rowIsVisible( i+1 ) ) )
		return;
	setTopCell( QMAX( 0, i - viewHeight()/cellHeight()/2 ) );
}
Exemple #9
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 )]) );
}
/** 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 );
}
Exemple #11
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;
}
Exemple #12
0
void DiffView::setCenterOffset(int offset)
{
    if (!rowIsVisible(offset))
    {
        int visiblerows = viewHeight()/cellHeight(0);
        setTopCell( qMax(0, offset - visiblerows/2) );
    }
}
Exemple #13
0
void TodoView::updateItem(int row, int col)
{
  QString tmpStr;
  int x=0, y=0;
  int id;

  updatingRow = row;

  ASSERT(row >= 0);
  editingFlag = TRUE;

  tmpStr = text(row, 0);
  id = atol(tmpStr.data());
  aTodo = calendar->getTodo(id);

  editor->hide();
  editor->setText(aTodo->getSummary());

  colXPos(col, &x);
  rowYPos(row, &y);
  y += 17; // correct for header size.

  // first, see if they clicked on the "done/not done column";
  if (col == 1) {
    tmpStr = text(row, 1);
    if (tmpStr == "CHECKED" || tmpStr == "CHECKEDMASK") {      
      aTodo->setStatus(QString("NEEDS ACTION"));
      changeItemPart("EMPTY", row, 1);
    } else {
      aTodo->setDtEnd(QDateTime::currentDateTime());
      aTodo->setStatus(QString("COMPLETED"));
      changeItemPart("CHECKED", row, 1);
    }
  }

  // see if they clicked on the "priority" column
  if (col == 2) {
    priList->move(x, y+2);
    priList->setCurrentItem(aTodo->getPriority()-1);
    priList->setFocus();
    priList->show();
  }

  // they clicked on the "description" column
  if (col == 3) {
    editor->move(x, y+2);
    editor->setFixedWidth(columnWidth(3));
    editor->setFixedHeight(cellHeight(row));
    editor->setFocus();
    editor->show();
  }
  if (col == 4) {
    // handle due date stuff
  }
  adjustColumns();
}
Exemple #14
0
//==================================================================
QSize KCharSelectTable::sizeHint() const
{
    int w = cellWidth();
    int h = cellHeight();

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

    return QSize( w, h );
}
Exemple #15
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 );
}
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() );
    }
}
Exemple #17
0
// virtual from QtTableView
void TableBody::scrollTrigger(int rx, int ry)
{
    if (ry == 0)
        return;
    int n = ry / cellHeight();
    /// printf("ry=%d n=%d\n",ry,n);
    if (ry > 0)
        tablecache.cutDown(n); // error?
    else
        tablecache.cutUp(-n);
    //	printf("ry=%d cellheight=%d n=%d\n",ry,cellHeight(),n);
}
Exemple #18
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();
}
Exemple #19
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);
        }
    }
}
Exemple #20
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));
    }
}
Exemple #21
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;
}
Exemple #22
0
void KFinderWin::setBranchVisible( KFinderItem* startItem )
{
  KFinderItem* curItem;
  int i1 = -1, i2 = -1;
  int branchLevel = -1;
  bool bFound = false;
  QListIterator<KFinderItem> it( itemList );
  //for ( ; it.current(); ++it )
  for ( curItem = finder->first(); curItem != 0; curItem = finder->next() )
  {
    if( bFound ){
      i2++;
      if( curItem->getLevel() <= branchLevel )
        break;
    }
    else {
      i1++;
      if( curItem == startItem ) {
	branchLevel = curItem->getLevel();
	i2 = i1;
	bFound = true;
      }    
    }
  }
  
  int lastRow = lastRowVisible();
  if( (i2 - i1) > lastRow - topCell() - 2 )
    setTopCell( i1 ? (i1 - 1) : i1 );
  else if( i2 > lastRow ) {
         int newTopCell = topCell() + ( i2 - lastRow );
         if( findRow(minViewY() + cellHeight() - 1) != topCell())
           newTopCell++;
         setTopCell( newTopCell );
       }
       else if( i1 < topCell() ) {
         int newTopCell = topCell() - ( topCell() - i1 );
	 if( newTopCell )
           newTopCell--;
         setTopCell( newTopCell );
       }	 
}
Exemple #23
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));
}
Exemple #24
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);
}
Exemple #25
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) );
    }
QSize VRFSystemMiniView::cellSize()
{
  return QSize(cellWidth(),cellHeight() + headerHeight());
}
QRectF VRFSystemMiniView::contentRect() const
{
  return QRectF(0,headerHeight(),cellWidth(),cellHeight());
}
Exemple #28
0
int MarkListTable::rowHeight()
{
	return cellHeight();
}
Exemple #29
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() );
	}
}
Exemple #30
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());
}