示例#1
0
	void Txtr::duplicateRectangleEdges(int x, int y, int width, int height)
	{
		if ( ! hasImage()) return;

		restrain<int>(x, 0, this->width-1);
		restrain<int>(y, 0, this->height-1);

		restrain<int>(width, 1, this->width-x);
		restrain<int>(height, 1, this->height-y);

		dAssert((x >= 0) && (y >= 0));
			
		int leftSpace = x;
		int bottomSpace = y;
		int rightSpace = this->width - (x+width);
		int topSpace = this->height - (y+height);

		// duplicate in four directions

		duplicateColumn(x, y, height, -1, leftSpace); // left area
		duplicateColumn(x+width-1, y, height, 1, rightSpace); // right area
		duplicateRow(x, y, width, -1, bottomSpace); // bottom area
		duplicateRow(x, y+height-1, width, 1, topSpace); // bottom area	

		//selectAndDuplicate(x, y, 0, 1, height, -1, 0, leftSpace); // left area
		//selectAndDuplicate(x, y, 1, 0, width, 0, -1, bottomSpace); // bottom area
		//selectAndDuplicate(x+width, y+height, 0, -1, height, 1, 0, rightSpace); // right area
		//selectAndDuplicate(x+width, y+height, -1, 0, width, 0, 1, topSpace); // top area

		//// duplicate the duplicates into the corners

		//selectAndDuplicate(x, y, 0, -1, bottomSpace, -1, -1, leftSpace); // left bottom down
		//selectAndDuplicate(x, y, -1, 0, leftSpace, -1, -1, leftSpace); // left bottom left

		//selectAndDuplicate(x, y+height, -1, 0, leftSpace, -1, 1, leftSpace); // left top left
		//selectAndDuplicate(x, y+height, 0, 1, topSpace, -1, 1, leftSpace); // left top up		

		//selectAndDuplicate(x+width, y+height, 0, 1, topSpace, 1, 1, rightSpace); // right top up
		//selectAndDuplicate(x+width, y+height, 1, 0, rightSpace, 1, 1, rightSpace); // right top right

		//selectAndDuplicate(x+width, y, 1, 0, rightSpace, 1, -1, rightSpace); // right bottom right
		//selectAndDuplicate(x+width, y, 0, -1, bottomSpace, 1, -1, rightSpace); // right bottom down

		// fill corners

		fillArea(0, 0, leftSpace, bottomSpace, getPixel(x, y)); // left bottom
		fillArea(0, y+height, leftSpace, topSpace, getPixel(x, y+height-1)); // top left
		fillArea(x+width, y+height, rightSpace, topSpace, getPixel(x+width-1, y+height-1)); // top right
		fillArea(x+width, 0, rightSpace, bottomSpace, getPixel(x+width-1, y)); // right bottom
		
	}
示例#2
0
//! Initialisierungsroutine
void PrintWidget::init(Database* DB)
{
  //! Zeiger übernehmen
  _DB = DB;

  //! ListView füllen
  fillArea();

  QFont font = ui->textEdit->currentFont();

  font.setPointSize(10);

  ui->textEdit->setFont(font);

  //! Grösse anpassen
  int iWidth = width();

  QList<int> lstWidth;

  lstWidth.append(iWidth * 0.40);
  lstWidth.append(iWidth - (iWidth * 0.40));

  ui->splitter->setSizes(lstWidth);
  ui->splitter->refresh();
}
示例#3
0
文件: fotolab.cpp 项目: rduga/fotolab
/**
 * Activates all action buttons.
 */
void FotoLab::activateActions()
{
	connect(ui.actionClose, SIGNAL(triggered()), qApp, SLOT(quit()));
	connect(ui.actionOpen, SIGNAL(triggered()), this, SLOT(openImage()));
	connect(ui.actionReload, SIGNAL(triggered()), this, SLOT(reloadImageData()));
	connect(ui.actionSaveAs, SIGNAL(triggered()), this, SLOT(saveImage()));
	connect(ui.actionAreaColor, SIGNAL(triggered()), this, SLOT(showColorDialog()));

	connect(ui.actionFillArea, SIGNAL(triggered()), ui.graphicsView, SLOT(fillArea()));
	connect(ui.actionCut, SIGNAL(triggered()), this, SLOT(cutArea()));
	connect(ui.actionEdges, SIGNAL(triggered()), this, SLOT(proposeEdges()));
	connect(ui.actionLines, SIGNAL(triggered()), this, SLOT(proposeLines()));

	connect(ui.actionDrawArea, SIGNAL(triggered()), ui.graphicsView, SLOT(switchDrawing()));

	//	connect(ui.actionProcess, SIGNAL(triggered()), ui.graphicsView, SLOT(processErase()));
	connect(ui.actionProcess, SIGNAL(triggered()), ui.graphicsView, SLOT(processShowEdges()));
	connect(ui.actionProperties, SIGNAL(triggered()), this, SLOT(showProperties()));

	connect(ui.actionHelpAbout, SIGNAL(triggered()), this, SLOT(showHelpAbout()));
	//	processShowEdges

	connect(ui.actionZoomIn, SIGNAL(triggered()), ui.graphicsView, SLOT(zoomIn()));
	connect(ui.actionZoomOut, SIGNAL(triggered()), ui.graphicsView, SLOT(zoomOut()));
	connect(ui.actionZoomNormal, SIGNAL(triggered()), ui.graphicsView, SLOT(zoomNormal()));

	connect(ui.actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));

	connect(&tlowSpin, SIGNAL(valueChanged(double)), this, SLOT(validateLowTreshold(double)));
	connect(&thighSpin, SIGNAL(valueChanged(double)), this, SLOT(validateHighTreshold(double)));
}
示例#4
0
void draw_dash() {
	unsigned char text[4] = "test";
	unsigned char *text_pointer = text;
	int x = 1;
	int *x_pointer = &x;
	fillArea(0, LCD_HEIGHT_PX-dash_height, LCD_WIDTH_PX, dash_height, COLOR_BLACK);
	PrintMini(x_pointer, x_pointer, text_pointer, 0, 0, 0, 0, 0, 0, 0, 0);
}
示例#5
0
文件: atlas.c 项目: SIEGE/siege
int main(void)
{
    sgInit(0);

    sgWindowOpen(WIDTH, HEIGHT, 32, 0);
    sgWindowSetTitle("SIEGE Atlas Demo");

    SGAtlas* atlas = sgAtlasCreate(ASIZE, ASIZE, 32);

    SGAtlasArea* area;

    size_t i;
    size_t num = 0;
    for(i = 0; i < NUMTEST; i++)
    {
        area = sgAtlasAreaReserve(atlas, BORDER + 12 + rand() % 5, BORDER + 12 + rand() % 5, SG_FALSE);
        if(area)
        {
            fillArea(atlas, area);
            num++;
        }
    }
    printf("Successfully inserted: %u/%u items\n", (unsigned int)num, NUMTEST);

    while(sgLoop(NULL))
    {
        sgDrawColor1f(1.0);
        sgAtlasDrawDBG(atlas, (WIDTH - ASIZE) / 2, (HEIGHT - ASIZE) / 2, 0, SG_FALSE);

        sgDrawColor3f(0.0, 1.0, 0.0);
        sgAtlasDrawDBG(atlas, (WIDTH - ASIZE) / 2, (HEIGHT - ASIZE) / 2, 0, SG_TRUE);

        sgWindowSwapBuffers();
        sgDrawClear();
    }

    sgAtlasDestroy(atlas);

    sgDeinit();

    return 0;
}
示例#6
0
/*!
 * \brief DrawingArea::mouseReleaseEvent Действие при отпускании левой кнопки мышки.
 * \param event Элемент действия
 *
 * Проверяет переменную myTool и по её номеру подбирает действие, которое следует совершить с изображением.
 * Задаёт функцию для обработки действия и после её совершения объявляет переменную scribbling = false.
 *
 */
void DrawingArea::mouseReleaseEvent(QMouseEvent *event)
{
    if (event->button() == Qt::LeftButton && scribbling && (myTool == 1))
    {
        drawLineTo(event->pos());
        scribbling = false;
    }
    else if(event->button() == Qt::LeftButton && scribbling && (myTool == 2 || 3))
    {
        bottomRight = event->pos();
        drawFigure(topLeft, bottomRight);
        scribbling = false;
    }
    if(event->button() == Qt::LeftButton && scribbling && (myTool == 4))
    {
        //lastPoint = event->pos();
        printf("painting!!!1\n");
        QColor clr;
        clr.fromRgb(image.pixel(lastPoint));
        fillArea(lastPoint, clr);

        scribbling = false;
    }
}
示例#7
0
void World::updateView(WorldPosition* positions, Size count, ViewCallback& callback) {
    for(Size i = 0; i < count; i++) {
        fillArea(Tritium::Math::roundInt(positions[i].x), Tritium::Math::roundInt(positions[i].y), callback);
    }
}
示例#8
0
void Document::cutLayer()
{
	copyFromLayer(m_toolctrl->activeLayer());
	fillArea(Qt::white, paintcore::BlendMode::MODE_ERASE);
}
void QTorrentItemDelegat::drawTorrent(QPainter* painter, const QStyleOptionViewItem& option, const Torrent& tor, const QModelIndex& index) const
{
	QStyleOptionViewItemV4 opt = option;
	initStyleOption(&opt, index);
	QStyle* style;

	if(opt.widget != NULL)
	{
		style = opt.widget->style();
	}
	else
	{
		style = QApplication::style();
	}

	const int iconSize(style->pixelMetric(QStyle::PM_LargeIconSize));
	QFont nameFont(option.font);
	nameFont.setWeight(QFont::Bold);
	const QFontMetrics nameFM(nameFont);
	const QIcon mimeIcon(tor.GetMimeTypeIcon());
	QString nameStr(tor.GetName());
	QSize nameSize(nameFM.size(0, nameStr));
	QFont statusFont(option.font);
	statusFont.setPointSize(int (option.font.pointSize() * 0.9));
	const QFontMetrics statusFM(statusFont);
	QString statusStr(GetStatusString(tor));
	int statusWidth = statusFM.width(statusStr);
	QFont progressFont(statusFont);
	const QFontMetrics progressFM(progressFont);
	QString progressStr(GetProgressString(tor));
	bool isPaused(tor.isPaused());
	painter->save();
	painter->setRenderHint(QPainter::Antialiasing);
	style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget);
	/* if (option.state & QStyle::State_Selected) {
	     QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
	             ? QPalette::Active : QPalette::Disabled;
	     if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
	         cg = QPalette::Inactive;


	    painter->fillRect(option.rect, opt.backgroundBrush);
	 }*/
	//style->drawControl(QStyle::CE_ItemViewItem,&option,painter);
	QIcon::Mode im;

	if(isPaused || !(option.state & QStyle::State_Enabled))
	{
		im = QIcon::Disabled;
	}
	else if(option.state & QStyle::State_Selected)
	{
		im = QIcon::Selected;
	}
	else
	{
		im = QIcon::Normal;
	}

	QIcon::State qs;

	if(isPaused)
	{
		qs = QIcon::Off;
	}
	else
	{
		qs = QIcon::On;
	}

	QPalette::ColorGroup cg = QPalette::Normal;

	if(isPaused || !(option.state & QStyle::State_Enabled))
	{
		cg = QPalette::Disabled;
	}

	if(cg == QPalette::Normal && !(option.state & QStyle::State_Active))
	{
		cg = QPalette::Inactive;
	}

	QPalette::ColorRole cr;

	if(option.state & QStyle::State_Selected)
	{
		cr = QPalette::HighlightedText;
	}

	cr = QPalette::Text;
	// layout
	const QSize m(margin(*style));
	QRect fillArea(option.rect);
	fillArea.adjust(m.width(), m.height(), -m.width(), -m.height());
	QRect iconArea(fillArea.x(), fillArea.y() + (fillArea.height() - iconSize) / 2, iconSize, iconSize);
	QRect nameArea(iconArea.x() + iconArea.width() + GUI_PAD, fillArea.y(),
	               fillArea.width() - GUI_PAD - iconArea.width(), nameSize.height());

	if (nameArea.width() + nameArea.x() > opt.rect.width())
	{
		nameArea.setWidth(opt.rect.width() - nameArea.x());
	}

	QRect barArea(nameArea.x(), nameArea.y() + statusFM.lineSpacing() + GUI_PAD / 2, nameArea.width(), BAR_HEIGHT);
	QRect progArea(nameArea.x(), barArea.y() + barArea.height() + GUI_PAD / 2, barArea.width() - statusWidth, nameArea.height());
	QRect statusArea(progArea.x() + progArea.width(), progArea.y(), statusWidth, progArea.height());

	if(tor.hasError())
	{
		painter->setPen(QColor("red"));
	}
	else
	{
		painter->setPen(opt.palette.color(cg, cr));
	}

	mimeIcon.paint(painter, iconArea, Qt::AlignCenter, im, qs);
	painter->setFont(nameFont);
	nameStr = nameFM.elidedText(nameStr, Qt::ElideRight, nameArea.width());
	style->drawItemText(painter, nameArea, Qt::AlignLeft, opt.palette, option.state & QStyle::State_Enabled, nameStr);
	painter->setFont(statusFont);
	statusStr = statusFM.elidedText(statusStr, Qt::ElideRight, statusArea.width());
	style->drawItemText(painter,  statusArea, Qt::AlignRight, opt.palette, option.state & QStyle::State_Enabled, statusStr);
	painter->setFont(progressFont);
	progressStr = statusFM.elidedText(progressStr, Qt::ElideRight, progArea.width());
	style->drawItemText(painter, progArea, Qt::AlignLeft, opt.palette, option.state & QStyle::State_Enabled, progressStr);
	int progressPercentage = tor.GetProgress();
	myProgressBarStyle->resize(barArea.size());
	myProgressBarStyle->setValue(progressPercentage);
	//painter->translate(barArea.topLeft());
	//myProgressBarStyle->render(painter);
	QStyleOptionProgressBarV2 pbStyleOpt;
	myProgressBarStyle->initilizeStyleOption(&pbStyleOpt);
	pbStyleOpt.rect = barArea;
	/*myProgressBarStyle->rect = barArea;
	if ( tor.isDownloading() ) {
	    myProgressBarStyle->palette.setBrush( QPalette::Highlight, blueBrush );
	    myProgressBarStyle->palette.setColor( QPalette::Base, blueBack );
	    myProgressBarStyle->palette.setColor( QPalette::Background, blueBack );
	}
	else if ( tor.isSeeding() ) {
	    myProgressBarStyle->palette.setBrush( QPalette::Highlight, greenBrush );
	    myProgressBarStyle->palette.setColor( QPalette::Base, greenBack );
	    myProgressBarStyle->palette.setColor( QPalette::Background, greenBack );
	}

	myProgressBarStyle->state = progressBarState;
	setProgressBarPercentDone( option, tor );
	*/
	style->drawControl(QStyle::CE_ProgressBar, &pbStyleOpt, painter, myProgressBarStyle);
	painter->restore();
}