Esempio n. 1
0
void CharSelect::slot_insertUserSpecialChar(QChar ch, QString font)
{
	if (!m_Item)
		return;
	PageItem_TextFrame *cItem;
	if (m_doc->appMode == modeEditTable)
		cItem = m_Item->asTable()->activeCell().textFrame();
	else
		cItem = m_Item->asTextFrame();
	if (cItem->HasSel)
		cItem->deleteSelectedTextFromFrame();
	cItem->invalidateLayout();
// 	//CB: Avox please make text->insertchar(char) so none of this happens in gui code, and item can tell doc its changed so the view and mainwindow slotdocch are not necessary
	if (ch == QChar(10))
		ch = QChar(13);
	if (ch == QChar(9))
		ch = QChar(32);
	int pot = cItem->itemText.cursorPosition();
	cItem->itemText.insertChars(ch, true);
	CharStyle nstyle = m_Item->itemText.charStyle(pot);
	nstyle.setFont((*m_doc->AllFonts)[font]);
	cItem->itemText.applyCharStyle(pot, 1, nstyle);
	m_doc->view()->DrawNew();
	m_doc->changed();
}
Esempio n. 2
0
void gtAction:: setCharStyleAttributes(gtFont *font, CharStyle& style)
{
	int flags = font->getFlags();
	style.erase();

	if ((flags & gtFont::familyWasSet) || (flags & gtFont::weightWasSet) || (flags & gtFont::slantWasSet))
		style.setFont(validateFont(font));
	if (flags & gtFont::sizeWasSet)
		style.setFontSize(font->getSize());
	if (flags & gtFont::effectWasSet)
		style.setFeatures(static_cast<StyleFlag>(font->getEffectsValue()).featureList());
	if (flags & gtFont::fillColorWasSet)
		style.setFillColor(parseColor(font->getColor()));
	if (flags & gtFont::fillShadeWasSet)
		style.setFillShade(font->getShade());
	if (flags & gtFont::strokeColorWasSet)
		style.setStrokeColor(parseColor(font->getStrokeColor()));
	if (flags & gtFont::strokeShadeWasSet)
		style.setStrokeShade(font->getStrokeShade());
	if (flags & gtFont::hscaleWasSet)
		style.setScaleH(font->getHscale());
	if (flags & gtFont::kerningWasSet)
		style.setTracking(font->getKerning());
}
Esempio n. 3
0
void CharSelect::slot_insertSpecialChar()
{
	emit insertSpecialChar();

	if (!m_Item)
		return;
	PageItem_TextFrame *cItem;
	if (m_doc->appMode == modeEditTable)
		cItem = m_Item->asTable()->activeCell().textFrame();
	else
		cItem = m_Item->asTextFrame();
	if (cItem->HasSel)
		cItem->deleteSelectedTextFromFrame();
	cItem->invalidateLayout();
	//CB: Avox please make text->insertchar(char) so none of this happens in gui code, and item can tell doc its changed so the view and mainwindow slotdocch are not necessary
	QChar ch;
	QString fontName = m_doc->currentStyle.charStyle().font().scName();
	if (m_enhanced)
		fontName = m_enhanced->getUsedFont();
	for (int a=0; a<chToIns.length(); ++a)
	{
		ch = chToIns.at(a);
		if (ch == QChar(10))
			ch = QChar(13);
		if (ch == QChar(9))
			ch = QChar(32);
		int pot = cItem->itemText.cursorPosition();
		cItem->itemText.insertChars(ch, true);
		CharStyle nstyle = m_Item->itemText.charStyle(pot);
		nstyle.setFont((*m_doc->AllFonts)[fontName]);
		cItem->itemText.applyCharStyle(pot, 1, nstyle);
	}
	m_doc->view()->DrawNew();
	m_doc->changed();
// 	delEdit();
}
Esempio n. 4
0
/*! 03.01.2007 - 05.01.2007 : Joachim Neu : Create a char style.
			Special thanks go to avox for helping me! */
PyObject *scribus_createcharstyle(PyObject* /* self */, PyObject* args, PyObject* keywords)
{
	char* keywordargs[] = {
					  							const_cast<char*>("name"),
					  							const_cast<char*>("font"),
					  							const_cast<char*>("fontsize"),
					  							const_cast<char*>("features"),
					  							const_cast<char*>("fillcolor"),
					  							const_cast<char*>("fillshade"),
					  							const_cast<char*>("strokecolor"),
					  							const_cast<char*>("strokeshade"),
					  							const_cast<char*>("baselineoffset"),
					  							const_cast<char*>("shadowxoffset"),
					  							const_cast<char*>("shadowyoffset"),
					  							const_cast<char*>("outlinewidth"),
					  							const_cast<char*>("underlineoffset"),
					  							const_cast<char*>("underlinewidth"),
					  							const_cast<char*>("strikethruoffset"),
					  							const_cast<char*>("strikethruwidth"),
					  							const_cast<char*>("scaleh"),
					  							const_cast<char*>("scalev"),
					  							const_cast<char*>("tracking"),
					  							const_cast<char*>("language"),
					  						NULL};
	char *Name = const_cast<char*>(""), *Font = const_cast<char*>("Times"), *Features = const_cast<char*>("inherit"), *FillColor = const_cast<char*>("Black"), *StrokeColor = const_cast<char*>("Black"), *Language = const_cast<char*>("");
	double FontSize = 200, FillShade = 1, StrokeShade = 1, ScaleH = 1, ScaleV = 1, BaselineOffset = 0, ShadowXOffset = 0, ShadowYOffset = 0, OutlineWidth = 0, UnderlineOffset = 0, UnderlineWidth = 0, StrikethruOffset = 0, StrikethruWidth = 0, Tracking = 0;
	if (!PyArg_ParseTupleAndKeywords(args, keywords, "es|esdesesdesddddddddddddes", keywordargs,
																									"utf-8", &Name, "utf-8", &Font, &FontSize, "utf-8", &Features,
																									"utf-8", &FillColor, &FillShade, "utf-8", &StrokeColor, &StrokeShade, &BaselineOffset, &ShadowXOffset,
																									&ShadowYOffset, &OutlineWidth, &UnderlineOffset, &UnderlineWidth, &StrikethruOffset, &StrikethruWidth,
																									&ScaleH, &ScaleV, &Tracking, "utf-8", &Language))
		return NULL;
	if(!checkHaveDocument())
		return NULL;
	if(Name == EMPTY_STRING)
	{
		PyErr_SetString(PyExc_ValueError, QObject::tr("Cannot have an empty char style name.","python error").toLocal8Bit().constData());
		return NULL;
	}

	QStringList FeaturesList = QString(Features).split(QString(","));

	CharStyle TmpCharStyle;
	TmpCharStyle.setName(Name);
	TmpCharStyle.setFont((*ScCore->primaryMainWindow()->doc->AllFonts)[QString(Font)]);
	TmpCharStyle.setFontSize(FontSize * 10);
	TmpCharStyle.setFeatures(FeaturesList);
	TmpCharStyle.setFillColor(QString(FillColor));
	TmpCharStyle.setFillShade(FillShade * 100);
	TmpCharStyle.setStrokeColor(QString(StrokeColor));
	TmpCharStyle.setStrokeShade(StrokeShade * 100);
	TmpCharStyle.setBaselineOffset(BaselineOffset);
	TmpCharStyle.setShadowXOffset(ShadowXOffset);
	TmpCharStyle.setShadowYOffset(ShadowYOffset);
	TmpCharStyle.setOutlineWidth(OutlineWidth);
	TmpCharStyle.setUnderlineOffset(UnderlineOffset);
	TmpCharStyle.setUnderlineWidth(UnderlineWidth);
	TmpCharStyle.setStrikethruOffset(StrikethruOffset);
	TmpCharStyle.setStrikethruWidth(StrikethruWidth);
	TmpCharStyle.setScaleH(ScaleH * 1000);
	TmpCharStyle.setScaleV(ScaleV * 1000);
	TmpCharStyle.setTracking(Tracking);
	TmpCharStyle.setLanguage(QString(Language));

	StyleSet<CharStyle> TmpStyleSet;
	TmpStyleSet.create(TmpCharStyle);
	ScCore->primaryMainWindow()->doc->redefineCharStyles(TmpStyleSet, false);
	// PV - refresh the Style Manager window.
	// I thought that this can work but it doesn't:
	// ScCore->primaryMainWindow()->styleMgr()->reloadStyleView();
	// So the brute force setDoc is called...
	ScCore->primaryMainWindow()->styleMgr()->setDoc(ScCore->primaryMainWindow()->doc);

	Py_RETURN_NONE;
}