QChar CharLineEdit::separatorChar() const { QFontMetrics met = fontMetrics(); QChar arrow(0x25ba); if (met.inFont(arrow)) return arrow; else return QChar('|'); }
//================================================================== 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 FontRowTable::paintEvent( QPaintEvent* e ) { QFrame::paintEvent(e); QPainter p(this); p.setClipRegion(e->region()); QRect r = e->rect(); QFontMetrics fm = fontMetrics(); int ml = frameWidth()+margin() + 1 + QMAX(0,-fm.minLeftBearing()); int mt = frameWidth()+margin(); QSize cell((width()-15-ml)/16,(height()-15-mt)/16); if ( !cell.width() || !cell.height() ) return; int mini = r.left() / cell.width(); int maxi = (r.right()+cell.width()-1) / cell.width(); int minj = r.top() / cell.height(); int maxj = (r.bottom()+cell.height()-1) / cell.height(); int h = fm.height(); QColor body(255,255,192); QColor negative(255,192,192); QColor positive(192,192,255); QColor rnegative(255,128,128); QColor rpositive(128,128,255); for (int j = minj; j<=maxj; j++) { for (int i = mini; i<=maxi; i++) { if ( i < 16 && j < 16 ) { int x = i*cell.width(); int y = j*cell.height(); QChar ch = QChar(j*16+i,row); if ( fm.inFont(ch) ) { int w = fm.width(ch); int l = fm.leftBearing(ch); int r = fm.rightBearing(ch); x += ml; y += mt+h; p.fillRect(x,y,w,-h,body); if ( w ) { if ( l ) { p.fillRect(x+(l>0?0:l), y-h/2, abs(l),-h/2, l < 0 ? negative : positive); } if ( r ) { p.fillRect(x+w-(r>0?r:0),y+2, abs(r),-h/2, r < 0 ? rnegative : rpositive); } } QString s; s += ch; p.setPen(QPen(Qt::black)); p.drawText(x,y,s); } } } } }