bool VCard_LDIFCreator::createImageBig()
{
  QFont normalFont( KGlobalSettings::generalFont() );
  QFont titleFont( normalFont );
  titleFont.setBold(true);
  // titleFont.setUnderline(true);
  titleFont.setItalic(true);

  QPainter painter(&mPixmap);
  painter.setFont(titleFont);
  QFontMetrics fm(painter.fontMetrics());

  // draw contact name
  painter.setClipRect(2, 2, pixmapSize.width()-4, pixmapSize.height()-4);
  QPoint p(5, fm.height()+2);
  painter.drawText(p, name);
  p.setY( 3*p.y()/2 );

  // draw contact information
  painter.setFont(normalFont);
  fm = painter.fontMetrics();

  const QStringList list( text.split('\n', QString::SkipEmptyParts) );
  for ( QStringList::ConstIterator it = list.begin();
             p.y()<=pixmapSize.height() && it != list.end(); ++it ) {
     p.setY( p.y() + fm.height() );
     painter.drawText(p, *it);
  }

  return true;
}
예제 #2
0
void SmkMarkHighlighter::updateOption(void)
{
    format_.clear();
    regexp_.clear();

    QFont normalFont(qSmkApp()->option("font.family"),
                     qSmkApp()->option("font.size").toInt());
    QFont boldFont   = normalFont; boldFont.setBold(true);
    QFont italicFont = normalFont; italicFont.setItalic(true);

    QTextCharFormat boldFormat;
    boldFormat.setFont(boldFont);
    format_.append(boldFormat);
    regexp_.append(QRegExp("<b>.*</b>"));
    format_.append(boldFormat);
    regexp_.append(QRegExp("<blod>.*</blod>"));

    QTextCharFormat italicFormat;
    italicFormat.setFont(italicFont);
    format_.append(italicFormat);
    regexp_.append(QRegExp("<i>.*</i>"));
    format_.append(italicFormat);
    regexp_.append(QRegExp("<italic>.*</italic>"));

    QTextCharFormat codeFormat;
    codeFormat.setForeground(QColor(qSmkApp()->option("color.code")));
    format_.append(codeFormat);
    regexp_.append(QRegExp("^    .*"));

    QTextCharFormat linkFormat;
    linkFormat.setForeground(QColor(qSmkApp()->option("color.link")));
    format_.append(linkFormat);
    regexp_.append(QRegExp("!?\\[.*\\]\\(.*\\)"));

    QTextCharFormat htmlFormat;
    htmlFormat.setForeground(QColor(qSmkApp()->option("color.html")));
    format_.append(htmlFormat);
    regexp_.append(QRegExp("<[0-z,~!@#$%^&*()-+|{}|:;\"'<,>.?/\t ]+>"));

    QTextCharFormat headerFormat;
    headerFormat.setForeground(QColor(qSmkApp()->option("color.header")));
    format_.append(headerFormat);
    regexp_.append(QRegExp("^#.*"));
}
예제 #3
0
void MainWindow::paintEvent(QPaintEvent*)
{
    const QPoint start(width()/2, 0);
    const QPoint finalStop(width()/2, height());
    QLinearGradient gradient(start, finalStop);
    const QColor qtGreen(102, 176, 54);
    gradient.setColorAt(0, qtGreen.dark());
    gradient.setColorAt(0.5, qtGreen);
    gradient.setColorAt(1, qtGreen.dark());

    QPainter p(this);
    p.fillRect(0, 0, width(), height(), gradient);

    QFont headerFont("Sans Serif", 12, QFont::Bold);
    QFont normalFont("Sans Serif", 9, QFont::Normal);

    // draw it twice for shadow effect
    p.setFont(headerFont);
    QRect headerRect(1, 1, width(), 25);
    p.setPen(Qt::black);
    p.drawText(headerRect, Qt::AlignCenter, m_station.name());

    headerRect.moveTopLeft(QPoint(0, 0));
    p.setPen(Qt::white);
    p.drawText(headerRect, Qt::AlignCenter, m_station.name());

    p.setFont(normalFont);
    int pos = 40;
    for (int i = 0; i < m_times.count() && i < 9; ++i) {
        p.setPen(Qt::black);
        p.drawText(51, pos + 1, m_times.at(i).time());
        p.drawText(101, pos + 1, m_times.at(i).direction());

        p.setPen(Qt::white);
        p.drawText(50, pos, m_times.at(i).time());
        p.drawText(100, pos, m_times.at(i).direction());

        pos += 18;
    }
}
예제 #4
0
void ChessClockWidget::initLabels()
{
    QFont normalFont("Helvetica",24);

    pictureLabel_ = new QLabel;
    pictureLabel_->setPixmap( picPassive_ );

    timeUsedLabel_ = new QLabel;
    timeAverageLabel_ = new QLabel;
    turnLabel_=new QLabel;
    turnTimeLabel_=new QLabel;

    timeUsedLabel_->setFont(normalFont);
    timeAverageLabel_->setFont(normalFont);
    turnLabel_->setFont(normalFont);

    QFont turnTimeFont("Helvetica",36,QFont::Bold);
    turnTimeLabel_->setFont(turnTimeFont);

    loserLabel_ = new QLabel;
    loserLabel_->setPixmap(picLoser_);
    loserLabel_->setVisible(false);

}
예제 #5
0
파일: Headers.cpp 프로젝트: KDE/koffice
void KCRowHeader::paintEvent(QPaintEvent* event)
{
    register KCSheet * const sheet = m_pView->activeSheet();
    if (!sheet)
        return;

//     KCElapsedTime et( "Painting vertical header", KCElapsedTime::PrintOnlyTime );

    // FIXME Stefan: Make use of clipping. Find the repaint call after the scrolling.
    // kDebug(36004) << event->rect();

    // painting rectangle
    const QRectF paintRect = m_pView->zoomHandler()->viewToDocument(event->rect());

    // the painter
    QPainter painter(this);
    painter.scale(m_pView->zoomHandler()->zoomedResolutionX(), m_pView->zoomHandler()->zoomedResolutionY());
    painter.setRenderHint(QPainter::TextAntialiasing);

    // fonts
    QFont normalFont(painter.font());
    QFont boldFont(normalFont);
    boldFont.setBold(true);

    // background brush/color
    const QBrush backgroundBrush(palette().window());
    const QColor backgroundColor(backgroundBrush.color());

    // selection brush/color
    QColor selectionColor(palette().highlight().color());
    selectionColor.setAlpha(127);
    const QBrush selectionBrush(selectionColor);

    painter.setClipRect(paintRect);

    double yPos;
    // Get the top row and the current y-position
    int y = sheet->topRow(paintRect.y() + m_pCanvas->yOffset(), yPos);
    // Align to the offset
    yPos = yPos - m_pCanvas->yOffset();

    const KViewConverter *converter = m_pCanvas->viewConverter();
    const double width = converter->viewToDocumentX(this->width() - 1);

    QSet<int> selectedRows;
    QSet<int> affectedRows;
    if (!m_pView->selection()->referenceSelectionMode() && m_cellToolIsActive) {
        selectedRows = m_pView->selection()->rowsSelected();
        affectedRows = m_pView->selection()->rowsAffected();
    }
    // Loop through the rows, until we are out of range
    while (yPos <= paintRect.bottom() && y <= KS_rowMax) {
        const bool selected = (selectedRows.contains(y));
        const bool highlighted = (!selected && affectedRows.contains(y));

        const KCRowFormat* rowFormat = sheet->rowFormat(y);
        if (rowFormat->isHiddenOrFiltered()) {
            ++y;
            continue;
        }
        const double height = rowFormat->height();

        if (selected || highlighted) {
            painter.setPen(selectionColor.dark(150));
            painter.setBrush(selectionBrush);
        } else {
            painter.setPen(backgroundColor.dark(150));
            painter.setBrush(backgroundBrush);
        }
        painter.drawRect(QRectF(0, yPos, width, height));

        QString rowText = QString::number(y);

        // Reset painter
        painter.setFont(normalFont);
        painter.setPen(palette().text().color());

        if (selected)
            painter.setPen(palette().highlightedText().color());
        else if (highlighted)
            painter.setFont(boldFont);

        const int ascent = painter.fontMetrics().ascent();
        if (height >= ascent - painter.fontMetrics().descent()) {
            const double len = painter.fontMetrics().width(rowText);
#if 0
            switch (y % 3) {
            case 0: rowText = QString::number(height) + 'h'; break;
            case 1: rowText = QString::number(painter.fontMetrics().ascent()) + 'a'; break;
            case 2: rowText = QString::number(painter.fontMetrics().descent()) + 'd'; break;
            }
            //kDebug() << "font height: " << painter.fontMetrics().ascent();
            painter.drawLine(1, yPos, 4, yPos + 3);
#endif
            drawText(painter,
                     normalFont,
                     QPointF((width - len) / 2,
                             yPos + (height - ascent) / 2),
//                            yPos + ( height - painter.fontMetrics().ascent() - painter.fontMetrics().descent() ) / 2 ),
                     rowText);
        }

        yPos += rowFormat->height();
        y++;
    }
}
예제 #6
0
파일: Headers.cpp 프로젝트: KDE/koffice
void KCColumnHeader::paintEvent(QPaintEvent* event)
{
    register KCSheet * const sheet = m_pView->activeSheet();
    if (!sheet)
        return;

//     KCElapsedTime et( "Painting horizontal header", KCElapsedTime::PrintOnlyTime );

    // FIXME Stefan: Make use of clipping. Find the repaint call after the scrolling.
    // kDebug(36004) << event->rect();

    // painting rectangle
    const QRectF paintRect = m_pView->zoomHandler()->viewToDocument(event->rect());

    // the painter
    QPainter painter(this);
    painter.scale(m_pView->zoomHandler()->zoomedResolutionX(), m_pView->zoomHandler()->zoomedResolutionY());
    painter.setRenderHint(QPainter::TextAntialiasing);

    // fonts
    QFont normalFont(painter.font());
    QFont boldFont(normalFont);
    boldFont.setBold(true);

    // background brush/color
    const QBrush backgroundBrush(palette().window());
    const QColor backgroundColor(backgroundBrush.color());

    // selection brush/color
    QColor selectionColor(palette().highlight().color());
    selectionColor.setAlpha(127);
    const QBrush selectionBrush(selectionColor);

    painter.setClipRect(paintRect);

    double xPos;
    int x;

    if (sheet->layoutDirection() == Qt::RightToLeft) {
        //Get the left column and the current x-position
        x = sheet->leftColumn(int(m_pView->zoomHandler()->unzoomItX(width()) - paintRect.x() + m_pCanvas->xOffset()), xPos);
        //Align to the offset
        xPos = m_pView->zoomHandler()->unzoomItX(width()) - xPos + m_pCanvas->xOffset();
    } else {
        //Get the left column and the current x-position
        x = sheet->leftColumn(int(paintRect.x() + m_pCanvas->xOffset()), xPos);
        //Align to the offset
        xPos = xPos - m_pCanvas->xOffset();
    }

    const KViewConverter *converter = m_pCanvas->viewConverter();
    const double height = converter->viewToDocumentY(this->height() - 1);

    if (sheet->layoutDirection() == Qt::RightToLeft) {
        if (x > KS_colMax)
            x = KS_colMax;

        xPos -= sheet->columnFormat(x)->width();

        QSet<int> selectedColumns;
        QSet<int> affectedColumns;
        if (!m_pView->selection()->referenceSelectionMode() && m_cellToolIsActive) {
            selectedColumns = m_pView->selection()->columnsSelected();
            affectedColumns = m_pView->selection()->columnsAffected();
        }
        //Loop through the columns, until we are out of range
        while (xPos <= paintRect.right() && x <= KS_colMax) {
            bool selected = (selectedColumns.contains(x));
            bool highlighted = (!selected && affectedColumns.contains(x));

            const KCColumnFormat* columnFormat = sheet->columnFormat(x);
            if (columnFormat->isHiddenOrFiltered()) {
                ++x;
                continue;
            }
            double width = columnFormat->width();

            if (selected || highlighted) {
                painter.setPen(selectionColor.dark(150));
                painter.setBrush(selectionBrush);
            } else {
                painter.setPen(backgroundColor.dark(150));
                painter.setBrush(backgroundBrush);
            }
            painter.drawRect(QRectF(xPos, 0, width, height));

            // Reset painter
            painter.setFont(normalFont);
            painter.setPen(palette().text().color());

            if (selected)
                painter.setPen(palette().highlightedText().color());
            else if (highlighted)
                painter.setFont(boldFont);

            QString colText = sheet->getShowColumnNumber() ? QString::number(x) : KCCell::columnName(x);
            double len = painter.fontMetrics().width(colText);
            if (width >= len) {
                drawText(painter,
                         normalFont,
                         QPointF(xPos + (width - len) / 2,
                                 (height - painter.fontMetrics().ascent() - painter.fontMetrics().descent()) / 2),
                         colText,
                         width);
            }
            xPos += columnFormat->width();
            --x;
        }
    } else { // if ( sheet->layoutDirection() == Qt::LeftToRight )
        QSet<int> selectedColumns;
        QSet<int> affectedColumns;
        if (!m_pView->selection()->referenceSelectionMode() && m_cellToolIsActive) {
            selectedColumns = m_pView->selection()->columnsSelected();
            affectedColumns = m_pView->selection()->columnsAffected();
        }
        //Loop through the columns, until we are out of range
        while (xPos <= paintRect.right() && x <= KS_colMax) {
            bool selected = (selectedColumns.contains(x));
            bool highlighted = (!selected && affectedColumns.contains(x));

            const KCColumnFormat *columnFormat = sheet->columnFormat(x);
            if (columnFormat->isHiddenOrFiltered()) {
                ++x;
                continue;
            }
            double width = columnFormat->width();

            QColor backgroundColor = palette().window().color();

            if (selected || highlighted) {
                painter.setPen(selectionColor.dark(150));
                painter.setBrush(selectionBrush);
            } else {
                painter.setPen(backgroundColor.dark(150));
                painter.setBrush(backgroundBrush);
            }
            painter.drawRect(QRectF(xPos, 0, width, height));

            // Reset painter
            painter.setFont(normalFont);
            painter.setPen(palette().text().color());

            if (selected)
                painter.setPen(palette().highlightedText().color());
            else if (highlighted)
                painter.setFont(boldFont);

            QString colText = sheet->getShowColumnNumber() ? QString::number(x) : KCCell::columnName(x);
            int len = painter.fontMetrics().width(colText);
            if (width >= len) {
#if 0
                switch (x % 3) {
                case 0: colText = QString::number(height) + 'h'; break;
                case 1: colText = QString::number(painter.fontMetrics().ascent()) + 'a'; break;
                case 2: colText = QString::number(painter.fontMetrics().descent()) + 'd'; break;
                }
#endif
                drawText(painter,
                         normalFont,
                         QPointF(xPos + (width - len) / 2,
                                 (height - painter.fontMetrics().ascent() - painter.fontMetrics().descent()) / 2),
                         colText,
                         width);
            }

            xPos += columnFormat->width();
            ++x;
        }
    }
}
RecipeView::RecipeView(UserAreaModel _area, RecipeModel _recipe){
   
    lastTouched = getElapsedSeconds();
    
    recipeModel = _recipe;
    areaModel = _area;
    timeOut = areaModel.timeout;
    // menu_img.load(_model.getMenuImage());
    debugState = 2;
    
    curStep = 0;
    stepState = 0;
    prevStepState = -1;
    prevStep = -1;
    
    pos = Vec2f(_area.x,_area.y);
    rotation = _area.r;
    
    align=TOP_LEFT;
    
    if(_area.name.compare("bottom-left")==0) align=BOTTOM_LEFT;
    if(_area.name.compare("bottom-right")==0) align=BOTTOM_RIGHT;
    if(_area.name.compare("top-left")==0){
     align=BOTTOM_RIGHT;
        console() << "aligning top left";
    }
    if(_area.name.compare("top-right")==0){
        align=BOTTOM_LEFT;
    console() << "aligning top right";
    }
    console() << "this recipemodel has this many steps: " << recipeModel.getNumSteps() << "." << endl;
    for(int i=0;i<recipeModel.getNumSteps();i++){
        console() << "wtf: " << recipeModel.getCookStep(i).img.at(0) << endl;
        gallerytools::Image anImage;
        anImage.load(recipeModel.getCookStep(i).img.at(recipeModel.curLanguage));
        anImage.hide();
        images.push_back(anImage);
        gallerytools::Video aVideo;
        console() << "loading video::: " << aVideo.load(recipeModel.getCookStep(i).video.at(recipeModel.curLanguage)) << endl;
        aVideo.hide();
        videos.push_back(aVideo);
    }
    back_btn.load(areaModel.back_btn.path);
    back_btn.moveTo(areaModel.back_btn.x,areaModel.back_btn.y,false);
    fwd_btn.load(areaModel.fwd_btn.path);
    fwd_btn.moveTo(areaModel.fwd_btn.x,areaModel.fwd_btn.y,false);
    select_btn.load(areaModel.select_btn.path);
    select_btn.moveTo(areaModel.select_btn.x,areaModel.select_btn.y,false);
    
    string normalFont( "Arial" );
    
	TextLayout layout;
	layout.clear( ColorA( 0.5f, 0.5f, 0.5f, 0.5f ) );
	layout.setFont( Font( normalFont, 24 ) );
	layout.setColor( Color( 1, 1, 1 ) );
	layout.addLine( "testing here");
	Surface8u rendered = layout.render( true, false );
	text_texture = gl::Texture( rendered );
    select_btn.setHalfHidden();
    back_btn.setHalfHidden();
    fwd_btn.setHalfHidden();
    
}
예제 #8
0
void GraphicTimeLine::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/) {

	// draw a non-opaque white rectangle for the background
	painter->setPen(Qt::NoPen);
	painter->setBrush(QColor(255, 255, 255, 200));
	painter->drawRect(boundingRect());

	QFont normalFont("Liberation Sans",9,QFont::Normal);
	QPen thickPen(Qt::black, 2);
	QPen thinPen(Qt::black, 1);
	AstroDate currentDate = itsScene->getStartDay();
	AstroDate endDate = itsScene->getEndDay();

	painter->setPen(thickPen);
	painter->setFont(normalFont);

	zoom_level zl = itsScene->getZoomLevel();

	if (zl == ZM_MONTH) {
		unsigned int month;
		int xMonthPos, xWeekPos;
		//draw the first week tick
		QString weekStr = QString::number(currentDate.getWeek());
		painter->drawLine(0, 15, 0, 17);
		painter->drawText(-35, 27, "Week: ");
		painter->drawText(16 - (weekStr.length()-1)*5, 27, weekStr);

		// draw the base time line
		painter->setPen(thinPen);
		painter->drawLine(0, 15, itsWidth, 15);

		unsigned int lastMonth(currentDate.getMonth());
		currentDate = currentDate.addDays(7);
		QString monthStr;
		while (currentDate <= endDate) {
			month = currentDate.getMonth();
			if (month != lastMonth) { // draw month inset
				xMonthPos = itsScene->time2xPos(AstroDate(1,month,currentDate.getYear())) - itsScenePos;
				painter->setPen(thickPen);
				painter->drawLine(xMonthPos, 5, xMonthPos, 17);
				painter->setPen(thinPen);
				monthStr = QString(MONTH_NAMES_ENG[month-1]) + " (" + QString::number(currentDate.getYear()) + ")";
				painter->drawText(QPoint(xMonthPos + 50 - monthStr.length()/2, 11), monthStr);
				lastMonth = month;
			}
			xWeekPos = itsScene->time2xPos(currentDate) - itsScenePos;
			painter->drawLine(xWeekPos, 15, xWeekPos, 17); // week ticks
			weekStr = QString::number(currentDate.getWeek());
			painter->drawText(QPoint(xWeekPos + 16 - (weekStr.length()-1)*5, 27), weekStr);
			currentDate = currentDate.addDays(7);
		}
		xWeekPos = itsScene->time2xPos(currentDate) - itsScenePos;
		painter->drawLine(xWeekPos, 15, xWeekPos, 17); // last week thick
	}
	else if (zl == ZM_WEEK) {
		unsigned int week;
		int xDayPos, xWeekPos;
		//draw the first day tick
		QString dayStr = QString::number(currentDate.getDay());
		QString weekStr;
		painter->drawLine(0, 15, 0, 17);
		painter->drawText(-35, 27, "Day:");
		painter->drawText(20 - (dayStr.length()-1)*5, 27, dayStr);

		// draw the base time line
		painter->setPen(thinPen);
		painter->drawLine(0, 15, itsWidth, 15);

		unsigned int lastWeek(currentDate.getWeek());
		currentDate = currentDate.addDays(1);
		while (currentDate <= endDate) {
			week = currentDate.getWeek();
			if (week != lastWeek) { // draw week inset
				xWeekPos = itsScene->time2xPos(currentDate) - itsScenePos;
				painter->setPen(thickPen);
				painter->drawLine(xWeekPos, 5, xWeekPos, 17);
				painter->setPen(thinPen);
				weekStr = "week " + QString::number(currentDate.getWeek()) + " ("
					+ MONTH_SHORT_NAMES_ENG[currentDate.getMonth()-1] + " " + QString::number(currentDate.getYear()) + ")";
				painter->drawText(QPoint(xWeekPos + 120 /*- weekStr.length()*4*/, 11), weekStr);
				lastWeek = week;
			}
			xDayPos = itsScene->time2xPos(currentDate) - itsScenePos;
			painter->drawLine(xDayPos, 15, xDayPos, 17); // day ticks
			dayStr = QString::number(currentDate.getDay());
			painter->drawText(QPoint(xDayPos + 20 - (dayStr.length()-1)*5, 27), dayStr);
			currentDate = currentDate.addDays(1);
		}
		xDayPos = itsScene->time2xPos(currentDate) - itsScenePos;
		painter->drawLine(xDayPos, 15, xDayPos, 17); // last day thick
	}
	else if (zl == ZM_DAY) {
        painter->drawText(-65, 27, "Hour (UTC)");
		// draw the base time line
		painter->setPen(thinPen);
		painter->drawLine(0, 15, itsWidth, 15);
		QString dayStr;
		int xDayPos;
		while (currentDate <= endDate) {
			xDayPos = itsScene->time2xPos(currentDate) - itsScenePos;
			dayStr = QString(DAY_SHORT_NAMES_ENG[currentDate.getDayOfTheWeek()]) + " "
				+ QString::number(currentDate.getDay()) + " "
				+ MONTH_SHORT_NAMES_ENG[currentDate.getMonth()-1] + ", "
				+ QString::number(currentDate.getYear());
			painter->drawText(xDayPos + 15, 13, dayStr);
			painter->drawLine(xDayPos, 5, xDayPos, 19);
			for (unsigned int hour = 0; hour < 24; ++hour) {
				painter->drawLine(xDayPos + hour * 5, 15, xDayPos + hour * 5, 17);
			}
			painter->drawLine(xDayPos + 60, 15, xDayPos + 60, 19); // 12:00 hour longer tick
			currentDate = currentDate.addDays(1);
		}
		xDayPos = itsScene->time2xPos(currentDate) - itsScenePos;
		painter->drawLine(xDayPos, 5, xDayPos, 19); // last day thick
	}
	else if (zl == ZM_HOUR) {
        painter->drawText(-65, 27, "Hour (UTC)");
		// draw the base time line
		painter->setPen(thinPen);
		QString dayStr;
		int xDayPos;
		while (currentDate <= endDate) {
			xDayPos = itsScene->time2xPos(currentDate) - itsScenePos;
			dayStr = QString(DAY_NAMES_ENG[currentDate.getDayOfTheWeek()]) + " "
					+ QString::number(currentDate.getDay()) + " "
					+ MONTH_NAMES_ENG[currentDate.getMonth()-1] + ", "
					+ QString::number(currentDate.getYear());
			painter->drawText(xDayPos + 180, 13, dayStr);
            painter->drawImage(xDayPos -1, 3, *itsTimeLineDayImage1);
			currentDate = currentDate.addDays(1);
		}
		xDayPos = itsScene->time2xPos(currentDate) - itsScenePos;
	}
	else if (zl == ZM_MIN) {
        painter->drawText(-65, 27, "Hour (UTC)");
		// draw the base time line
        QString dayStr;
		int xDayPos;
		painter->setPen(thinPen);
		while (currentDate <= endDate) {
			xDayPos = itsScene->time2xPos(currentDate) - itsScenePos;
			dayStr = QString(DAY_NAMES_ENG[currentDate.getDayOfTheWeek()]) + " "
					+ QString::number(currentDate.getDay()) + " "
					+ MONTH_NAMES_ENG[currentDate.getMonth()-1] + ", "
					+ QString::number(currentDate.getYear());
			painter->drawText(xDayPos + 180, 13, dayStr);
            painter->drawImage(xDayPos -7, 0, *itsTimeLineDayImage2);
			currentDate = currentDate.addDays(1);
		}
		xDayPos = itsScene->time2xPos(currentDate) - itsScenePos;
	}

//	painter->setPen(QPen(Qt::magenta, 0.5));
//	painter->drawRect(boundingRect());
	// for test purpose: draw boundings
//	painter->setPen(QPen(Qt::magenta, 1.0));
//	painter->setBrush(Qt::NoBrush);
//	painter->drawRect(boundingRect());

}
예제 #9
0
void CtrlDisAsmView::paintEvent(QPaintEvent *)
{
	QPainter painter(this);
	painter.setBrush(Qt::white);
	painter.setPen(Qt::white);
	painter.drawRect(rect());

	struct branch
	{
		int src,dst,srcAddr;
		bool conditional;
	};
	branch branches[256];
	int numBranches=0;

	int width = rect().width();
	int numRows=(rect().height()/rowHeight);

	QColor bgColor(0xFFFFFFFF);
	QPen nullPen(bgColor);
	QPen currentPen(QColor(0,0,0));
	QPen selPen(QColor(0xFF808080));
	QPen condPen(QColor(0xFFFF3020));

	QBrush lbr;
	lbr.setColor(bgColor);
	QBrush currentBrush(QColor(0xFFFFEfE8));
	QBrush pcBrush(QColor(0xFF70FF70));

	QFont normalFont("Arial", 10);
	QFont boldFont("Arial", 10);
	QFont alignedFont("Monospace", 10);
	alignedFont.setStyleHint(QFont::Monospace);
	boldFont.setBold(true);
	painter.setFont(normalFont);


	QImage breakPoint(":/resources/breakpoint.ico");
	int i;
	curAddress&=~(align-1);

	align=(debugger->getInstructionSize(0));
	for (i=0; i<=numRows; i++)
	{
		unsigned int address=curAddress + (i-(numRows/2))*align;

		int rowY1 = rect().top() + rowHeight*i;
		int rowY2 = rect().top() + rowHeight*i + rowHeight - 1;

		lbr.setColor((unsigned int)marker == address ? QColor(0xFFFFEEE0) : QColor(debugger->getColor(address)));
		QColor bg = lbr.color();
		painter.setBrush(currentBrush);
		painter.setPen(nullPen);
		painter.drawRect(0,rowY1,16-1,rowY2-rowY1);

		if (selecting && address == (unsigned int)selection)
			painter.setPen(selPen);
		else
		{
			if(i==numRows/2)
				painter.setPen(currentPen);
			else
				painter.setPen(bg);
		}
		painter.setBrush(QBrush(bg));

		if (address == debugger->getPC())
		{
			painter.setBrush(pcBrush);
		}

		painter.drawRect(16,rowY1,width-16-1,rowY2-rowY1);
		painter.setBrush(currentBrush);
		QPen textPen(QColor(halfAndHalf(bg.rgba(),0)));
		painter.setPen(textPen);
		painter.setFont(alignedFont);
		painter.drawText(17,rowY1-3+rowHeight,QString("%1").arg(address,8,16,QChar('0')));
		painter.setFont(normalFont);
		textPen.setColor(QColor(0xFF000000));
		painter.setPen(textPen);
		if (debugger->isAlive())
		{
			const char *dizz = debugger->disasm(address, align);
			char dis[512];
			strcpy(dis, dizz);
			char *dis2 = strchr(dis,'\t');
			char desc[256]="";
			if (dis2)
			{
				*dis2=0;
				dis2++;
				const char *mojs=strstr(dis2,"->$");
				if (mojs)
				{
					for (int i=0; i<8; i++)
					{
						bool found=false;
						for (int j=0; j<22; j++)
						{
							if (mojs[i+3]=="0123456789ABCDEFabcdef"[j])
								found=true;
						}
						if (!found)
						{
							mojs=0;
							break;
						}
					}
				}
				if (mojs)
				{
					int offs;
					sscanf(mojs+3,"%08x",&offs);
					branches[numBranches].src=rowY1 + rowHeight/2;
					branches[numBranches].srcAddr=address/align;
					branches[numBranches].dst=(int)(rowY1+((s64)offs-(s64)address)*rowHeight/align + rowHeight/2);
					branches[numBranches].conditional = (dis[1]!=0); //unconditional 'b' branch
					numBranches++;
					const char *t = debugger->getDescription(offs).c_str();
					if (memcmp(t,"z_",2)==0)
						t+=2;
					if (memcmp(t,"zz_",3)==0)
						t+=3;
					sprintf(desc,"-->%s", t);
					textPen.setColor(QColor(0xFF600060));
					painter.setPen(textPen);
				}
				else
				{
					textPen.setColor(QColor(0xFF000000));
					painter.setPen(textPen);
				}
				painter.drawText(149,rowY1-3+rowHeight,QString(dis2));
			}
			textPen.setColor(QColor(0xFF007000));
			painter.setPen(textPen);
			painter.setFont(boldFont);
			painter.drawText(84,rowY1-3+rowHeight,QString(dis));
			painter.setFont(normalFont);
			if (desc[0]==0)
			{
				const char *t = debugger->getDescription(address).c_str();
				if (memcmp(t,"z_",2)==0)
					t+=2;
				if (memcmp(t,"zz_",3)==0)
					t+=3;
				strcpy(desc,t);
			}
			if (memcmp(desc,"-->",3) == 0)
			{
				textPen.setColor(QColor(0xFF0000FF));
				painter.setPen(textPen);
			}
			else
			{
				textPen.setColor(halfAndHalf(halfAndHalf(bg.rgba(),0),bg.rgba()));
				painter.setPen(textPen);
			}
			if (strlen(desc))
				painter.drawText(std::max(280,width/3+190),rowY1-3+rowHeight,QString(desc));
			if (debugger->isBreakpoint(address))
			{
				painter.drawImage(2,rowY1+2,breakPoint);
			}
		}
	}
	for (i=0; i<numBranches; i++)
	{
		painter.setPen(branches[i].conditional ? condPen : currentPen);
		int x=280+(branches[i].srcAddr%9)*8;
		QPoint curPos(x-2,branches[i].src);

		if (branches[i].dst<rect().bottom()+200 && branches[i].dst>-200)
		{
			painter.drawLine(curPos, QPoint(x+2,branches[i].src));
			curPos = QPoint(x+2,branches[i].src);
			painter.drawLine(curPos, QPoint(x+2,branches[i].dst));
			curPos = QPoint(x+2,branches[i].dst);
			painter.drawLine(curPos, QPoint(x-4,branches[i].dst));

			curPos = QPoint(x,branches[i].dst-4);
			painter.drawLine(curPos, QPoint(x-4,branches[i].dst));
			curPos = QPoint(x-4,branches[i].dst);
			painter.drawLine(curPos, QPoint(x+1,branches[i].dst+5));
		}
		else
		{
			painter.drawLine(curPos, QPoint(x+4,branches[i].src));
		}
	}
}
예제 #10
0
void CtrlMemView::paintEvent(QPaintEvent *)
{
	QPainter painter(this);
	painter.setBrush(Qt::white);
	painter.setPen(Qt::white);
	painter.drawRect(rect());

	if (!debugger)
		return;

	int width = rect().width();
	int numRows=(rect().bottom()/rowHeight)/2+1;

	QPen nullPen(0xFFFFFF);
	QPen currentPen(0xFF000000);
	QPen selPen(0x808080);
	QBrush lbr(0xFFFFFF);
	QBrush nullBrush(0xFFFFFF);
	QBrush currentBrush(0xFFEFE8);
	QBrush pcBrush(0x70FF70);
	QPen textPen;

	QFont normalFont("Arial", 10);
	QFont alignedFont("Monospace", 10);
	alignedFont.setStyleHint(QFont::Monospace);
	painter.setFont(normalFont);

	int i;
	curAddress&=~(align-1);
	for (i=-numRows; i<=numRows; i++)
	{
		unsigned int address=curAddress + i*align*alignMul;

		int rowY1 = rect().bottom()/2 + rowHeight*i - rowHeight/2;
		int rowY2 = rect().bottom()/2 + rowHeight*i + rowHeight/2;

		char temp[256];

		painter.setBrush(currentBrush);

		if (selecting && address == (unsigned int)selection)
		  painter.setPen(selPen);
		else
		  painter.setPen(i==0 ? currentPen : nullPen);
		painter.drawRect(0, rowY1, 16-1, rowY2 - rowY1 - 1);

		painter.drawRect(16, rowY1, width - 16 -1, rowY2 - rowY1 - 1);
		painter.setBrush(nullBrush);
		textPen.setColor(0x600000);
		painter.setPen(textPen);
		painter.setFont(alignedFont);
		painter.drawText(17,rowY1-2+rowHeight, QString("%1").arg(address,8,16,QChar('0')));
		textPen.setColor(0xFF000000);
		painter.setPen(textPen);
		if (debugger->isAlive())
		{

			switch(mode) {
			case MV_NORMAL:
				{
					const char *m = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
					if (Memory::IsValidAddress(address))
					{
						u32 memory[4] = {
							debugger->readMemory(address),
							debugger->readMemory(address+4),
							debugger->readMemory(address+8),
							debugger->readMemory(address+12)
						};
						m = (const char*)memory;
						sprintf(temp, "%08x %08x %08x %08x  ................",
							memory[0],memory[1],memory[2],memory[3]);
					}
					for (int i=0; i<16; i++)
					{
						int c = (unsigned char)m[i];
						if (c>=32 && c<255)
							temp[i+37]=c;
					}
				}
				painter.setFont(alignedFont);
				painter.drawText(85,rowY1 - 2 + rowHeight, temp);
			break;

			case MV_SYMBOLS:
				{
/*					textPen.setColor(0x0000FF);
					painter.setPen(textPen);
					int fn = g_symbolMap->GetSymbolNum(address);
					if (fn==-1)
					{
						sprintf(temp, "%s (ns)", Memory::GetAddressName(address));
					}
					else
						sprintf(temp, "%s (0x%x b)", g_symbolMap->GetSymbolName(fn),g_symbolMap->GetSymbolSize(fn));
					painter.drawText(205,rowY1 - 2 + rowHeight, temp);

					textPen.setColor(0xFF000000);
					painter.setPen(textPen);

					if (align==4)
					{
						u32 value = Memory::ReadUnchecked_U32(address);
						int symbolnum = g_symbolMap->GetSymbolNum(value);
						if(symbolnum>=0)
							sprintf(temp, "%08x [%s]", value, g_symbolMap->GetSymbolName(symbolnum));
					}
					else if (align==2)
					{
						u16 value = Memory::ReadUnchecked_U16(address);
						int symbolnum = g_symbolMap->GetSymbolNum(value);
						if(symbolnum>=0)
							sprintf(temp, "%04x [%s]", value, g_symbolMap->GetSymbolName(symbolnum));
					}

                    painter.drawText(85,rowY1 - 2 + rowHeight, temp);*/
					break;
				}
			case MV_MAX: break;
			}
		}
	}
}