From: <go...@us...> - 2010-11-04 13:55:52
|
Revision: 1257 http://qterm.svn.sourceforge.net/qterm/?rev=1257&view=rev Author: gonwan Date: 2010-11-04 13:55:46 +0000 (Thu, 04 Nov 2010) Log Message: ----------- Fix display positions and paddings. Better support for one-char-two-color characters. Modified Paths: -------------- trunk/qterm-qt4/src/main.cpp trunk/qterm-qt4/src/qtermscreen.cpp Modified: trunk/qterm-qt4/src/main.cpp =================================================================== --- trunk/qterm-qt4/src/main.cpp 2010-11-04 13:18:19 UTC (rev 1256) +++ trunk/qterm-qt4/src/main.cpp 2010-11-04 13:55:46 UTC (rev 1257) @@ -130,7 +130,7 @@ if ( strcmp( qVersion(), QT_MIN_VERSION ) < 0 ) { qFatal("QTerm requires Qt %s or above to run! Qt installed in your system is %s.", QT_MIN_VERSION, qVersion()); } - QApplication::setGraphicsSystem("raster"); + //QApplication::setGraphicsSystem("raster"); QApplication a( argc, argv ); a.setApplicationName("QTerm"); Modified: trunk/qterm-qt4/src/qtermscreen.cpp =================================================================== --- trunk/qterm-qt4/src/qtermscreen.cpp 2010-11-04 13:18:19 UTC (rev 1256) +++ trunk/qterm-qt4/src/qtermscreen.cpp 2010-11-04 13:55:46 UTC (rev 1257) @@ -1004,12 +1004,21 @@ if (GETBG(cp) != 0 || m_ePaintState == Cursor) painter.fillRect(mapToRect(x, y, length, 1), QBrush(m_color[GETBG(cp)])); if (flags == RenderAll) { - painter.drawText(pt.x()+m_nCharDelta, pt.y(), m_nCharWidth*length, m_nCharHeight, Qt::AlignLeft|Qt::AlignBottom, str); - } else if (flags == RenderLeft) { - painter.drawText(pt.x()+m_nCharDelta, pt.y(), m_nCharWidth-m_nCharDelta, m_nCharHeight, Qt::AlignLeft|Qt::AlignBottom, str); - } else if (flags == RenderRight) { - int width = painter.fontMetrics().width(str[0])-m_nCharWidth+m_nCharDelta; - painter.drawText(pt.x(), pt.y(), width, m_nCharHeight, Qt::AlignRight|Qt::AlignBottom, str); + painter.drawText(pt.x(), pt.y(), m_nCharWidth*length, m_nCharHeight, Qt::AlignCenter, str); + } else { + QPixmap pm = QPixmap(m_nCharWidth*2, m_nCharHeight); + QPainter p(&pm); + p.fillRect(0, 0, pm.width(), pm.height(), m_color[GETBG(cp)]); + p.setPen(m_color[GETFG(cp)]); + p.setFont(painter.font()); + p.drawText(0, 0, m_nCharWidth*2, m_nCharHeight, Qt::AlignCenter, str); + p.end(); + if (flags == RenderLeft) { + painter.drawPixmap(pt.x(), pt.y(), pm, 0, 0, m_nCharWidth, m_nCharHeight); + } + if (flags == RenderRight) { + painter.drawPixmap(pt.x(), pt.y(), pm, m_nCharWidth, 0, m_nCharWidth, m_nCharHeight); + } } } painter.setBackground(QBrush(m_color[0])); @@ -1090,9 +1099,9 @@ QPoint pt = mapToPixel(QPoint(x, y)); if (width == -1) // to the end - return QRect(pt.x()+m_nCharDelta, pt.y(), size().width() , m_nCharHeight*height); + return QRect(pt.x(), pt.y(), size().width() , m_nCharHeight*height); else - return QRect(pt.x()+m_nCharDelta, pt.y(), width*m_nCharWidth, m_nCharHeight*height); + return QRect(pt.x(), pt.y(), width*m_nCharWidth, m_nCharHeight*height); } QRect Screen::mapToRect(const QRect& rect) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |