Beispiel #1
0
/*
========================
updateWindowTitle
========================
*/
void CBaseEditWindow::updateWindowTitle( void )
{
	CSourceEdit* doc = activeDocument();
	if( doc != NULL )
	{
		// get the base file name
		QString title = extractFileNameFromPath( doc->fileName() );
		if( title.length() == 0 ) // source not assigned to a file
			title = QString( CONFIG_STRING_FILE_UNTITLED );

		// add 'modified' flag
		if( doc->document()->isModified() ) {
			title += tr( "*" );
		}

		// lookup the shader type name
		QString shType = QString( " (%1) " ).
			arg( IShader::getShaderTypeName( doc->shaderType() ) );

		// add app title
		title += shType; // show shader type in the window title
		title += QString( " - " CONFIG_STRING_APPLICATION_TITLE );

		setWindowTitle( title );
	}
	else // no active document
	{
		setWindowTitle( CONFIG_STRING_APPLICATION_TITLE );
	}
}
Beispiel #2
0
/*
========================
save
========================
*/
bool CBaseEditWindow::save( void )
{
	CSourceEdit* doc = activeDocument();
	if( doc != NULL )
		return doc->save();

	return false;
}
/**
 * Scripter.openDocument(filename)
 * filename is a string
 * returns opened active Document object
 */
QObject *ScripterImpl::openDocument(const QString & filename)
{
	bool ret = ScCore->primaryMainWindow()->loadDoc(filename);
	if (!ret)
	{
		RAISE("Failed to open " + filename);
		return NULL;
	}
	return activeDocument();
}
/**
 * Scripter.newDocument(topMargin, bottomMargin, leftMargin, rightMargin, pageWIdth, pageHeight, orientation, firstPageNr, pagesTypes, facingPages, firstPageOrger, numPages)
 * topMargin is double
 * bottomMargin is double
 * leftMargin is double
 * rightMargin is double
 * pageWidth is double
 * pageHeight is double
 * orientation is int
 * firstPageNr is int
 * unit is int
 * pagesType is int
 * facingPages is int
 * firstPageOrder is int
 * numPages is int
 * returns new a new active Document object
 */
QObject *ScripterImpl::newDocument(
    double topMargin, double bottomMargin,
    double leftMargin, double rightMargin,
    double pageWidth, double pageHeight,
    int orientation, int firstPageNr, int unit, int pagesType,
    int facingPages, int firstPageOrder, int numPages)
{
	if (numPages <= 0)
		numPages = 1;
	if (pagesType == 0)
	{
		facingPages = 0;
		firstPageOrder = 0;
	}
	else
		facingPages = 1;
	// checking the bounds
	if (pagesType < firstPageOrder)
	{
		RAISE("firstPageOrder is bigger than allowed.");
		return NULL;
	}
	if (orientation == 1)
	{
		double x = pageWidth;
		pageWidth = pageHeight;
		pageHeight = x;
	}
	bool ret = ScCore->primaryMainWindow()->doFileNew(
	               pageWidth, pageHeight, topMargin, leftMargin,
	               rightMargin, bottomMargin,
	               // XXX: add later?
	               // autoframes. It's disabled in python
	               // columnDistance, numberCols, autoframes,
	               0, 1, false,
	               pagesType, unit, firstPageOrder,
	               orientation, firstPageNr, "Custom", true, numPages);
	if (!ret)
	{
		RAISE("Page creation failed");
		return NULL;
	}
	ScCore->primaryMainWindow()->doc->setPageSetFirstPage(pagesType, firstPageOrder);
	return activeDocument();
}
Beispiel #5
0
/*
========================
open
========================
*/
void CBaseEditWindow::open( void )
{
	CSourceEdit* doc = activeDocument();
	if( doc != NULL )
		doc->open();
}
Beispiel #6
0
/*
========================
newFile
========================
*/
void CBaseEditWindow::newFile( void )
{
	CSourceEdit* doc = activeDocument();
	if( doc != NULL )
		doc->newFile();
}
Beispiel #7
0
void CBaseEditWindow::paste( void )
{
	QTextEdit* doc = activeDocument();
	if( doc != NULL ) { doc->paste(); }
}
Beispiel #8
0
void CBaseEditWindow::copy( void )
{
	QTextEdit* doc = activeDocument();
	if( doc != NULL ) { doc->copy(); }
}
Beispiel #9
0
void CBaseEditWindow::redo( void )
{
	QTextEdit* doc = activeDocument();
	if( doc != NULL ) { doc->redo(); }
}
Beispiel #10
0
	void FrameView::paintEvent(QPaintEvent *)
	{
		const int px_unit = font.pixelSize();
		const int px_hspace = px_unit * horizontal_factor;
		const int px_vspace = px_unit * vertical_factor;
		const int y_offset = viewport()->height()/2 - px_vspace/2;

		const DocInfo *dinfo = gui::activeDocInfo();

		m_currentFrame = dinfo->currentFrame();
		m_currentChannel = dinfo->currentChannel();
		int currentFrame = m_currentFrame;
		int currentChannel = m_currentChannel;

		const int frame_y_offset = y_offset - currentFrame*px_vspace;

		const QColor bg = stylecolor(styles::PATTERN_BG);

		QPainter p;
		p.begin(viewport());
		p.setPen(Qt::NoPen);
		p.setBrush(bg);
		p.drawRect(rect());

		{
			QLinearGradient lg(0, 0, 0, 1);
			lg.setColorAt(0, QColor(96, 96, 96));
			lg.setColorAt(1, QColor(64, 64, 64));
			lg.setCoordinateMode(QGradient::ObjectBoundingMode);

			p.setBrush(lg);
			p.drawRect(0, y_offset, viewport()->width(), px_vspace);
		}

		{
			p.setBrush(QColor(255,255,255,64));
			p.drawRect(px_hspace*(currentChannel+1), y_offset, px_hspace, px_vspace);
		}

		p.setFont(font);

		QTextOption opt;
		opt.setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);

		const QColor framenumcol = stylecolor(styles::PATTERN_HIGHLIGHT2_FG, true);

		p.setPen(framenumcol);
		p.setBrush(Qt::NoBrush);

		FtmDocument *d = activeDocument();

		int chans = 0;
		if (d != NULL)
		{
			 chans = d->GetAvailableChannels();
		}

		int num_frames = d->GetFrameCount();

		int viewport_height = viewport()->height();

		for (int i = 0; i < num_frames; i++)
		{
			int y = px_vspace*i+frame_y_offset;
			if (y+px_vspace < 0)
				continue;
			if (y > viewport_height)
				break;

			char buf[6];
			sprintf(buf, "%02X", i);

			p.drawText(QRect(0,y,px_hspace,px_vspace), buf, opt);
		}

		unsigned int active_patterns[MAX_CHANNELS];

		for (int i = 0; i < chans; i++)
		{
			active_patterns[i] = d->GetPatternAtFrame(currentFrame, i);
		}

		const QColor selectedpat = stylecolor(styles::PATTERN_FG, true);
		const QColor unselectedpat = stylecolor(styles::PATTERN_FG, false);


		for (int i = 0; i < num_frames; i++)
		{
			int y = px_vspace*i+frame_y_offset;
			if (y+px_vspace < 0)
				continue;
			if (y > viewport_height)
				break;
			for (int x = 0; x < chans; x++)
			{
				char buf[6];
				int pattern = d->GetPatternAtFrame(i, x);

				if (pattern == active_patterns[x])
				{
					p.setPen(selectedpat);
				}
				else
				{
					p.setPen(unselectedpat);
				}

				sprintf(buf, "%02X", pattern);
				p.drawText(QRect(px_hspace*(x+1),y,px_hspace,px_vspace), buf, opt);
			}
		}

		p.setPen(Qt::gray);
		p.drawLine(px_hspace,0,px_hspace,viewport()->height());

		p.end();
	}