r17963 by fschmid - Some work to make Radiobuttons and shaded Panels (Buttons) look better.

scribus-commit scribus-commit at lists.scribus.net
Sun Dec 16 18:55:10 UTC 2012


Author: fschmid
Date: Sun Dec 16 18:55:10 2012
New Revision: 17963

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17963
Log:
Some work to make Radiobuttons and shaded Panels (Buttons) look better.

Modified:
    trunk/Scribus/scribus/pageitem_textframe.cpp
    trunk/Scribus/scribus/pdflib_core.cpp
    trunk/Scribus/scribus/pdflib_core.h
    trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
    trunk/Scribus/scribus/scpainter.cpp
    trunk/Scribus/scribus/scpainter.h
    trunk/Scribus/scribus/ui/outlinepalette.cpp

Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17963&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp Sun Dec 16 18:55:10 2012
@@ -3144,23 +3144,29 @@
 			if (annotation().Type() == Annotation::RadioButton)
 			{
 				double bwh = annotation().Bwid() / 2.0;
-				QPainterPath clp;
-				clp.addEllipse(QRectF(bwh, bwh, Width - annotation().Bwid(), Height - annotation().Bwid()));
-				FPointArray clpArr;
-				clpArr.fromQPainterPath(clp);
-				p->setupPolygon(&clpArr);
-				p->setPen(tmp, annotation().Bwid(), annotation().Bsty() == 0 ? Qt::SolidLine : Qt::DashLine, Qt::FlatCap, Qt::MiterJoin);
-				p->setFillMode(ScPainter::None);
-				p->setStrokeMode(ScPainter::Solid);
-				p->strokePath();
+				if ((annotation().Bsty() == 0) || (annotation().Bsty() == 1))
+				{
+					QPainterPath clp;
+					clp.addEllipse(QRectF(bwh, bwh, Width - annotation().Bwid(), Height - annotation().Bwid()));
+					FPointArray clpArr;
+					clpArr.fromQPainterPath(clp);
+					p->setupPolygon(&clpArr);
+					p->setPen(tmp, annotation().Bwid(), annotation().Bsty() == 0 ? Qt::SolidLine : Qt::DashLine, Qt::FlatCap, Qt::MiterJoin);
+					p->setFillMode(ScPainter::None);
+					p->setStrokeMode(ScPainter::Solid);
+					p->strokePath();
+				}
+				else if (annotation().Bsty() == 3)
+					p->drawShadeCircle(QRectF(0, 0, Width, Height), tmp, false, annotation().Bwid());
+				else if (annotation().Bsty() == 4)
+					p->drawShadeCircle(QRectF(0, 0, Width, Height), tmp, true, annotation().Bwid());
 			}
 			else
 			{
-				QPalette pal = QPalette(tmp);
 				if (annotation().Bsty() == 3)
-					p->drawShadePanel(QRect(0, 0, Width, Height), pal, false, annotation().Bwid());
+					p->drawShadePanel(QRectF(0, 0, Width, Height), tmp, false, annotation().Bwid());
 				else if (annotation().Bsty() == 4)
-					p->drawShadePanel(QRect(0, 0, Width, Height), pal, true, annotation().Bwid());
+					p->drawShadePanel(QRectF(0, 0, Width, Height), tmp, true, annotation().Bwid());
 				else
 				{
 					p->setPen(tmp, annotation().Bwid(), annotation().Bsty() == 0 ? Qt::SolidLine : Qt::DashLine, Qt::FlatCap, Qt::MiterJoin);
@@ -3215,7 +3221,10 @@
 			if (annotation().IsChk())
 			{
 				QPainterPath clp2;
-				clp2.addEllipse(QRectF(annotation().Bwid() * 1.5, annotation().Bwid() * 1.5, width() - annotation().Bwid() * 3, height() - annotation().Bwid() * 3).normalized());
+				double siz = qMin(width(), height()) * 0.4;
+				QRectF sizR(0, 0, siz, siz);
+				sizR.moveCenter(QPointF(width() / 2.0, height() / 2.0));
+				clp2.addEllipse(sizR);
 				FPointArray clpArr2;
 				clpArr2.fromQPainterPath(clp2);
 				p->setBrush(fontColor);

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17963&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp (original)
+++ trunk/Scribus/scribus/pdflib_core.cpp Sun Dec 16 18:55:10 2012
@@ -8360,18 +8360,18 @@
 		QList<uint> kidsList;
 		uint parentObject = newObject();
 		QString onState = "";
-		for (int a = 0; a < bList.count(); a++)
-		{
-			uint kid = PDF_RadioButton(bList[a], parentObject);
-			kidsList.append(kid);
-			if (bList[a]->annotation().IsChk())
-				onState = QString("/%1").arg(bList[a]->itemName().replace(".", "_" ));
-		}
 		QString anTitle;
 		if (it.key() == 0)
 			anTitle = QString("Page%1").arg(ActPageP->pageNr() + 1);
 		else
 			anTitle = QString("/%1").arg(it.key()->itemName().replace(".", "_" ));
+		for (int a = 0; a < bList.count(); a++)
+		{
+			uint kid = PDF_RadioButton(bList[a], parentObject, anTitle);
+			kidsList.append(kid);
+			if (bList[a]->annotation().IsChk())
+				onState = QString("/%1").arg(bList[a]->itemName().replace(".", "_" ));
+		}
 		StartObj(parentObject);
 		Seite.AObjects.append(parentObject);
 		Seite.FormObjects.append(parentObject);
@@ -8379,6 +8379,7 @@
 		PutDoc("/Subtype /Widget\n");
 		PutDoc("/FT /Btn\n");
 		PutDoc("/T " + EncString(anTitle, parentObject) + "\n");
+		PutDoc("/Contents " + EncStringUTF16(anTitle, parentObject) + "\n");
 		PutDoc("/Ff "+QString::number(Annotation::Flag_Radio | Annotation::Flag_NoToggleToOff)+"\n");
 		PutDoc("/V "+onState+"\n");
 		PutDoc("/DV "+onState+"\n");
@@ -8393,7 +8394,7 @@
 	}
 }
 
-uint PDFLibCore::PDF_RadioButton(PageItem* ite, uint parent)
+uint PDFLibCore::PDF_RadioButton(PageItem* ite, uint parent, QString parentName)
 {
 	QMap<int, QString> ind2PDFabr;
 	static const QString bifonts[] = {"/Courier", "/Courier-Bold", "/Courier-Oblique", "/Courier-BoldOblique",
@@ -8416,9 +8417,9 @@
 	StartObj(annotationObj);
 	Seite.AObjects.append(annotationObj);
 	PutDoc("<<\n/Type /Annot\n");
-	Seite.FormObjects.append(annotationObj);
 	PutDoc("/Subtype /Widget\n");
 	PutDoc("/Parent " + QString::number(parent) + " 0 R\n");
+	PutDoc("/Contents " + EncStringUTF16(parentName, annotationObj) + "\n");
 	if (!ite->annotation().ToolTip().isEmpty())
 		PutDoc("/TU " + EncStringUTF16(ite->annotation().ToolTip(), annotationObj) + "\n");
 	PutDoc("/F ");
@@ -8504,48 +8505,28 @@
 	}
 	PutDoc("/Rect [ "+FToStr(x+bleedDisplacementX)+" "+FToStr(y2+bleedDisplacementY)+" "+FToStr(x2+bleedDisplacementX)+" "+FToStr(y+bleedDisplacementY)+" ]\n");
 	PutDoc(">>\nendobj\n");
-
-	double bwh = ite->annotation().Bwid() / 2.0;
-	QPainterPath clp;
-	clp.addEllipse(QRectF(bwh, bwh, ite->width() - ite->annotation().Bwid(), ite->height() - ite->annotation().Bwid()));
-	FPointArray clpArr;
-	clpArr.fromQPainterPath(clp);
-	clpArr.translate(0, -ite->height());
-	cc = "q\n";
-	cc += QString::number(ite->annotation().Bwid())+" w\n";
-	if (ite->annotation().borderColor() != CommonStrings::None)
-		cc += putColor(ite->annotation().borderColor(), 100.0, false);
-	else
-		cc += "0 G\n";
-	cc += SetClipPathArray(&clpArr, true);
-	cc += "h\nS\n";
+	cc = createBorderAppearance(ite);
 	if (ite->itemText.defaultStyle().charStyle().fillColor() != CommonStrings::None)
 		cc += putColor(ite->itemText.defaultStyle().charStyle().fillColor(), ite->itemText.defaultStyle().charStyle().fillShade(), true);
 	else if (ite->fillColor() != CommonStrings::None)
 		cc += putColor(ite->fillColor(), ite->fillShade(), true);
 	QPainterPath clp2;
-	clp2.addEllipse(QRectF(ite->annotation().Bwid() * 1.5, ite->annotation().Bwid() * 1.5, ite->width() - ite->annotation().Bwid() * 3, ite->height() - ite->annotation().Bwid() * 3).normalized());
+	double siz = qMin(ite->width(), ite->height()) * 0.4;
+	QRectF sizR(0, 0, siz, siz);
+	sizR.moveCenter(QPointF(ite->width() / 2.0, ite->height() / 2.0));
+	clp2.addEllipse(sizR);
 	FPointArray clpArr2;
 	clpArr2.fromQPainterPath(clp2);
 	clpArr2.translate(0, -ite->height());
 	cc += SetClipPathArray(&clpArr2, true);
 	cc += "h\nf\nQ\n";
 	PDF_xForm(appearanceObj1, ite->width(), ite->height(), cc);
-	cc = "";
-	cc = "q\n";
-	cc += QString::number(ite->annotation().Bwid())+" w\n";
-	if (ite->annotation().borderColor() != CommonStrings::None)
-		cc += putColor(ite->annotation().borderColor(), 100.0, false);
-	else
-		cc += "0 G\n";
-	cc += SetClipPathArray(&clpArr, true);
-	cc += "h\nS\n";
-	cc += "Q";
+	cc = createBorderAppearance(ite);
 	PDF_xForm(appearanceObj2, ite->width(), ite->height(), cc);
 	return annotationObj;
 }
 
-bool PDFLibCore::PDF_Annotation(PageItem *ite, uint)
+bool PDFLibCore::PDF_Annotation(PageItem *ite, uint PNr)
 {
 	ScImage img;
 	ScImage img2;
@@ -8582,6 +8563,8 @@
 	QString ct(m[ite->annotation().ChkStil()]);
 	uint annotationObj = newObject();
 	uint appearanceObj = 0;
+	uint appearanceObj1 = 0;
+	uint appearanceObj2 = 0;
 	uint icon1Obj = 0;
 	uint icon2Obj = 0;
 	uint icon3Obj = 0;
@@ -8591,6 +8574,7 @@
 	uint AActionObj = writeActions(ite->annotation(), annotationObj);
 	StartObj(annotationObj);
 	Seite.AObjects.append(annotationObj);
+	QString onState = QString("/%1").arg(ite->itemName().replace(".", "_" ));
 	PutDoc("<<\n/Type /Annot\n");
 	switch (ite->annotation().Type())
 	{
@@ -8675,6 +8659,8 @@
 					PutDoc(xs[ite->annotation().Feed()]);
 					PutDoc("\n");
 					PutDoc("/Q 0\n");
+					appearanceObj = newObject();
+					PutDoc("/AP << /N "+QString::number(appearanceObj)+" 0 R >>\n");
 					break;
 				case Annotation::Textfield:
 					PutDoc("/FT /Tx\n");
@@ -8688,10 +8674,16 @@
 					break;
 				case Annotation::Checkbox:
 					PutDoc("/FT /Btn\n");
-					PutDoc(ite->annotation().IsChk() ? "/V /Yes\n/DV /Yes\n/AS /Yes\n" :
-								"/V /Off\n/DV /Off\n/AS /Off\n");
-					appearanceObj = newObject();
-					PutDoc("/AP << /N << /Yes "+QString::number(appearanceObj)+" 0 R >> >>\n");
+					if (ite->annotation().IsChk())
+						PutDoc("/V "+onState+"\n/DV "+onState+"\n/AS "+onState+"\n");
+					else
+						PutDoc("/V /Off\n/DV /Off\n/AS /Off\n");
+					appearanceObj1 = newObject();
+					appearanceObj2 = newObject();
+					PutDoc("/AP << /N <<\n");
+					PutDoc(onState + " " + QString::number(appearanceObj1)+" 0 R\n");
+					PutDoc("/Off " + QString::number(appearanceObj2)+" 0 R\n");
+					PutDoc(">> >>\n");
 					break;
 				case Annotation::Combobox:
 				case Annotation::Listbox:
@@ -8937,12 +8929,35 @@
 		}
 	}
 	// write Appearance?
+	if (ite->annotation().Type() == Annotation::Button)
+	{
+		cc = "";
+		cc += "q 1 g\n";
+		cc += "0 0 "+FToStr(x2-x)+" "+FToStr(y-y2)+" re\nf\n";
+		cc += createBorderAppearance(ite);
+		cc += "BT\n";
+		if (ite->itemText.defaultStyle().charStyle().fillColor() != CommonStrings::None)
+			cc += putColor(ite->itemText.defaultStyle().charStyle().fillColor(), ite->itemText.defaultStyle().charStyle().fillShade(), true);
+		if (Options.Version < PDFOptions::PDFVersion_14)
+			cc += "/"+StdFonts[ind2PDFabr[ite->annotation().Font()]];
+		else
+			cc += UsedFontsF[ite->itemText.defaultStyle().charStyle().font().replacementName()];
+//			cc += UsedFontsP[ite->itemText.defaultStyle().charStyle().font().replacementName()]+"Form";
+		cc += " "+FToStr(ite->itemText.defaultStyle().charStyle().fontSize() / 10.0)+" Tf\n";
+		cc += "1 0 0 1 0 0 Tm\n0 0 Td\n";
+		if (bmstUtf16.count() > 0)
+			cc += EncStringUTF16(bmstUtf16[0], annotationObj);
+		cc += " Tj\nET\n";
+		cc += "Q\n";
+		PDF_xForm(appearanceObj, ite->width(), ite->height(), cc);
+	}
 	if (ite->annotation().Type() == Annotation::Textfield)
 	{
 		cc = "";
 		if (ite->fillColor() != CommonStrings::None)
 			cc += putColor(ite->fillColor(), ite->fillShade(), false);
 		cc += FToStr(x)+" "+FToStr(y2)+" "+FToStr(x2-x)+" "+FToStr(y-y2)+" re\nf\n";
+		cc += createBorderAppearance(ite);
 		cc += "/Tx BMC\nBT\n";
 		if (ite->itemText.defaultStyle().charStyle().fillColor() != CommonStrings::None)
 			cc += putColor(ite->itemText.defaultStyle().charStyle().fillColor(), ite->itemText.defaultStyle().charStyle().fillShade(), true);
@@ -8968,24 +8983,29 @@
 	}
 	if (ite->annotation().Type() == Annotation::Checkbox)
 	{
-		cc = "q\nBT\n";
+		cc = "";
+		cc += "q\n1 g\n";
+		cc += "0 0 "+FToStr(x2-x)+" "+FToStr(y-y2)+" re\nf\n";
+		cc += createBorderAppearance(ite);
+		cc += "BT\n";
 		if (ite->itemText.defaultStyle().charStyle().fillColor() != CommonStrings::None)
 			cc += putColor(ite->itemText.defaultStyle().charStyle().fillColor(), ite->itemText.defaultStyle().charStyle().fillShade(), true);
 		cc += "/"+StdFonts["/ZapfDingbats"]+" "+FToStr(ite->itemText.defaultStyle().charStyle().fontSize() / 10.0)+" Tf\n";
-		cc += "0 0 Td\n("+ct+") Tj\nET\nQ";
-		PDF_xForm(appearanceObj, ite->width(), ite->height(), cc);
+		cc += QString::number(ite->annotation().Bwid())+" "+QString::number(ite->annotation().Bwid())+" Td\n("+ct+") Tj\nET\nQ";
+		PDF_xForm(appearanceObj1, ite->width(), ite->height(), cc);
+		cc = "";
+		cc += "q\n1 g\n";
+		cc += "0 0 "+FToStr(x2-x)+" "+FToStr(y-y2)+" re\nf\n";
+		cc += createBorderAppearance(ite);
+		cc += "Q\n";
+		PDF_xForm(appearanceObj2, ite->width(), ite->height(), cc);
 	}
 	if ((ite->annotation().Type() == Annotation::Combobox) || (ite->annotation().Type() == Annotation::Listbox))
 	{
 		cc = "";
 		cc += "1 g\n";
 		cc += "0 0 "+FToStr(x2-x)+" "+FToStr(y-y2)+" re\nf\n";
-		cc += QString::number(ite->annotation().Bwid())+" w\n";
-		if (ite->annotation().borderColor() != CommonStrings::None)
-			cc += putColor(ite->annotation().borderColor(), 100.0, false);
-		else
-			cc += "0 G\n";
-		cc += "0 0 "+FToStr(x2-x)+" "+FToStr(y-y2)+" re\nS\n";
+		cc += createBorderAppearance(ite);
 		cc += "/Tx BMC\nq\nBT\n";
 		cc += "0 g\n";
 		if (Options.Version < PDFOptions::PDFVersion_14)
@@ -8995,12 +9015,167 @@
 //			cc += UsedFontsP[ite->itemText.defaultStyle().charStyle().font().replacementName()]+"Form";
 		cc += " "+FToStr(ite->itemText.defaultStyle().charStyle().fontSize() / 10.0)+" Tf\n";
 		cc += "1 0 0 1 0 0 Tm\n0 0 Td\n";
-		if (bmstUtf16.count() > 0)
-			cc += EncStringUTF16(bmstUtf16[0], annotationObj);
-		cc += " Tj\nET\nQ\nEMC";
+		if (ite->annotation().Type() == Annotation::Listbox)
+		{
+			if (bmstUtf16.count() > 1)
+			{
+				for (int mz = 0; mz < bmstUtf16.count(); ++mz)
+				{
+					cc += EncStringUTF16(bmstUtf16[mz], annotationObj);
+					cc += " Tj\nT*\n";
+				}
+				cc += "ET\nEMC";
+			}
+			else
+				cc += EncStringUTF16(bmUtf16, annotationObj) + " Tj\nET\nEMC";
+		}
+		else
+		{
+			if (bmstUtf16.count() > 0)
+				cc += EncStringUTF16(bmstUtf16[0], annotationObj) + " Tj\n";
+			cc += "ET\nQ\nEMC";
+		}
 		PDF_xForm(appearanceObj, ite->width(), ite->height(), cc);
 	}
 	return true;
+}
+
+QString PDFLibCore::createBorderAppearance(PageItem *ite)
+{
+	double dx = ite->width();
+	double dy = ite->height();
+	QString ret = "";
+	if (ite->annotation().borderColor() == CommonStrings::None)
+		return ret;
+	if (ite->annotation().Bwid() == 0)
+		return ret;
+	QColor tmp;
+	ite->SetQColor(&tmp, ite->annotation().borderColor(), 100);
+	ret += "q\n";
+	if (ite->annotation().Type() == Annotation::RadioButton)
+	{
+		if ((ite->annotation().Bsty() == 0) || (ite->annotation().Bsty() == 1))
+		{
+			ret += putColor(ite->annotation().borderColor(), 100, false);
+			ret += QString::number(ite->annotation().Bwid())+" w\n";
+			ret += "0 J\n";
+			ret += "0 j\n";
+			if (ite->annotation().Bsty() == 1)
+				ret += "["+QString::number(ite->annotation().Bwid()*4)+" "+QString::number(ite->annotation().Bwid()*2)+"] 0 d\n";
+			double bwh = ite->annotation().Bwid() / 2.0;
+			double rad = qMin(ite->width() - ite->annotation().Bwid(), ite->height() - ite->annotation().Bwid());
+			QPainterPath clp;
+			clp.addEllipse(QRectF(bwh, bwh, rad, rad));
+			FPointArray clpArr;
+			clpArr.fromQPainterPath(clp);
+			clpArr.translate(0, -ite->height());
+			ret += SetClipPathArray(&clpArr, true);
+			ret += "h\nS\n";
+		}
+		else if ((ite->annotation().Bsty() == 3) || (ite->annotation().Bsty() == 4))
+		{
+			QColor shade;
+			QColor light;
+			if (ite->annotation().Bsty() == 4)
+			{
+				shade.setRgbF(tmp.redF() * 0.5, tmp.greenF() * 0.5, tmp.blueF() * 0.5);
+				light.setRgbF(tmp.redF() * 0.5 + 0.5, tmp.greenF() * 0.5 + 0.5, tmp.blueF() * 0.5 + 0.5);
+			}
+			else
+			{
+				light.setRgbF(tmp.redF() * 0.5, tmp.greenF() * 0.5, tmp.blueF() * 0.5);
+				shade.setRgbF(tmp.redF() * 0.5 + 0.5, tmp.greenF() * 0.5 + 0.5, tmp.blueF() * 0.5 + 0.5);
+			}
+			ret += "0 J\n";
+			ret += "0 j\n";
+			ret += putColor(ite->annotation().borderColor(), 100, false);
+			double bwh = ite->annotation().Bwid() / 2.0;
+			int h, s, v;
+			double cx = dx / 2.0;
+			double cy = dy / 2.0;
+			double rb = 0.5 * (dx < dy ? dx : dy);
+			double r = rb - 0.25 * ite->annotation().Bwid();
+			double bzc = 0.55228475;
+			ret += QString::number(bwh)+" w\n";
+			ret += FToStr(cx + r)+" "+FToStr(cy)+" m\n";
+			ret += FToStr(cx + r)+" "+FToStr(cy + bzc * r)+" "+FToStr(cx + bzc * r)+" "+FToStr(cy + r)+" "+FToStr(cx)+" "+FToStr(cy + r)+" c\n";
+			ret += FToStr(cx - bzc * r)+" "+FToStr(cy + r)+" "+FToStr(cx - r)+" "+FToStr(cy + bzc * r)+" "+FToStr(cx - r)+" "+FToStr(cy)+" c\n";
+			ret += FToStr(cx - r)+" "+FToStr(cy - bzc * r)+" "+FToStr(cx - bzc * r)+" "+FToStr(cy - r)+" "+FToStr(cx)+" "+FToStr(cy - r)+" c\n";
+			ret += FToStr(cx + bzc * r)+" "+FToStr(cy - r)+" "+FToStr(cx + r)+" "+FToStr(cy - bzc * r)+" "+FToStr(cx + r)+" "+FToStr(cy)+" c\n";
+			ret += "h\nS\n";
+			r = rb - 0.73 * ite->annotation().Bwid();
+			double r2 = r / 1.414213562;
+			shade.getRgb(&h, &s, &v);
+			ret += FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0)+" RG\n";
+			ret += FToStr(cx + r2)+" "+FToStr(cy + r2)+" m\n";
+			ret += FToStr(cx + (1 - bzc) * r2)+" "+FToStr(cy + (1 + bzc) * r2)+" "+FToStr(cx - (1 - bzc) * r2)+" "+FToStr(cy + (1 + bzc) * r2)+" "+FToStr(cx - r2)+" "+FToStr(cy + r2)+" c\n";
+			ret += FToStr(cx - (1 + bzc) * r2)+" "+FToStr(cy + (1 - bzc) * r2)+" "+FToStr(cx - (1 + bzc) * r2)+" "+FToStr(cy - (1 - bzc) * r2)+" "+FToStr(cx - r2)+" "+FToStr(cy - r2)+" c\n";
+			ret += "S\n";
+			light.getRgb(&h, &s, &v);
+			ret += FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0)+" RG\n";
+			ret += FToStr(cx - r2)+" "+FToStr(cy - r2)+" m\n";
+			ret += FToStr(cx - (1 - bzc) * r2)+" "+FToStr(cy - (1 + bzc) * r2)+" "+FToStr(cx + (1 - bzc) * r2)+" "+FToStr(cy - (1 + bzc) * r2)+" "+FToStr(cx + r2)+" "+FToStr(cy - r2)+" c\n";
+			ret += FToStr(cx + (1 + bzc) * r2)+" "+FToStr(cy - (1 - bzc) * r2)+" "+FToStr(cx + (1 + bzc) * r2)+" "+FToStr(cy + (1 - bzc) * r2)+" "+FToStr(cx + r2)+" "+FToStr(cy + r2)+" c\n";
+			ret += "S\n";
+		}
+	}
+	else
+	{
+		if ((ite->annotation().Bsty() == 0) || (ite->annotation().Bsty() == 1))
+		{
+			ret += putColor(ite->annotation().borderColor(), 100, false);
+			ret += QString::number(ite->annotation().Bwid())+" w\n";
+			ret += "0 J\n";
+			ret += "0 j\n";
+			if (ite->annotation().Bsty() == 1)
+				ret += "["+QString::number(ite->annotation().Bwid()*4)+" "+QString::number(ite->annotation().Bwid()*2)+"] 0 d\n";
+			double bwh = ite->annotation().Bwid() / 2.0;
+			QPainterPath clp;
+			clp.addRect(QRectF(bwh, bwh, ite->width() - ite->annotation().Bwid(), ite->height() - ite->annotation().Bwid()));
+			FPointArray clpArr;
+			clpArr.fromQPainterPath(clp);
+			clpArr.translate(0, -ite->height());
+			ret += SetClipPathArray(&clpArr, true);
+			ret += "h\nS\n";
+		}
+		else if ((ite->annotation().Bsty() == 3) || (ite->annotation().Bsty() == 4))
+		{
+			QColor shade;
+			QColor light;
+			if (ite->annotation().Bsty() == 4)
+			{
+				shade.setRgbF(tmp.redF() * 0.5, tmp.greenF() * 0.5, tmp.blueF() * 0.5);
+				light.setRgbF(tmp.redF() * 0.5 + 0.5, tmp.greenF() * 0.5 + 0.5, tmp.blueF() * 0.5 + 0.5);
+			}
+			else
+			{
+				light.setRgbF(tmp.redF() * 0.5, tmp.greenF() * 0.5, tmp.blueF() * 0.5);
+				shade.setRgbF(tmp.redF() * 0.5 + 0.5, tmp.greenF() * 0.5 + 0.5, tmp.blueF() * 0.5 + 0.5);
+			}
+			int h, s, v;
+			shade.getRgb(&h, &s, &v);
+			ret += FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0)+" rg\n";
+			ret += "0 w\n";
+			ret += "0 0 m\n";
+			ret += "0 "+FToStr(dy)+" l\n";
+			ret += FToStr(dx)+" "+FToStr(dy)+" l\n";
+			ret += FToStr(dx - ite->annotation().Bwid())+" "+FToStr(dy - ite->annotation().Bwid())+" l\n";
+			ret += FToStr(ite->annotation().Bwid())+" "+FToStr(dy - ite->annotation().Bwid())+" l\n";
+			ret += FToStr(ite->annotation().Bwid())+" "+FToStr(ite->annotation().Bwid())+" l\n";
+			ret += "h\nf\n";
+			light.getRgb(&h, &s, &v);
+			ret += FToStr(h / 255.0)+" "+FToStr(s / 255.0)+" "+FToStr(v / 255.0)+" rg\n";
+			ret += "0 0 m\n";
+			ret += FToStr(dx)+" 0 l\n";
+			ret += FToStr(dx)+" "+FToStr(dy)+" l\n";
+			ret += FToStr(dx - ite->annotation().Bwid())+" "+FToStr(dy - ite->annotation().Bwid())+" l\n";
+			ret += FToStr(dx - ite->annotation().Bwid())+" "+FToStr(ite->annotation().Bwid())+" l\n";
+			ret += FToStr(ite->annotation().Bwid())+" "+FToStr(ite->annotation().Bwid())+" l\n";
+			ret += "h\nf\n";
+		}
+	}
+	ret += "Q\n";
+	return ret;
 }
 
 uint PDFLibCore::writeActions(const Annotation&	annot, uint annotationObj)

Modified: trunk/Scribus/scribus/pdflib_core.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17963&path=/trunk/Scribus/scribus/pdflib_core.h
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.h (original)
+++ trunk/Scribus/scribus/pdflib_core.h Sun Dec 16 18:55:10 2012
@@ -169,8 +169,9 @@
 	bool    PDF_3DAnnotation(PageItem *ite, uint PNr);
 #endif
 	void	PDF_RadioButtons();
-	uint    PDF_RadioButton(PageItem *ite, uint parent);
+	uint    PDF_RadioButton(PageItem *ite, uint parent, QString parentName);
 	bool    PDF_Annotation(PageItem *ite, uint PNr);
+	QString createBorderAppearance(PageItem *ite);
 	void    PDF_Form(const QString& im);
 	void    PDF_xForm(uint objNr, double w, double h, QString im);
 	bool    PDF_Image(PageItem* c, const QString& fn, double sx, double sy, double x, double y, bool fromAN = false, const QString& Profil = "", bool Embedded = false, eRenderIntent Intent = Intent_Relative_Colorimetric, QString* output = NULL);

Modified: trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17963&path=/trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/pdf/slaoutput.cpp Sun Dec 16 18:55:10 2012
@@ -700,6 +700,8 @@
 									ite->annotation().setChkStil(4);
 								else if (itemText == "n")
 									ite->annotation().setChkStil(5);
+								else
+									ite->annotation().setChkStil(0);
 							}
 						}
 						else if ((wtyp == Annotation::Combobox) || (wtyp == Annotation::Listbox))

Modified: trunk/Scribus/scribus/scpainter.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17963&path=/trunk/Scribus/scribus/scpainter.cpp
==============================================================================
--- trunk/Scribus/scribus/scpainter.cpp (original)
+++ trunk/Scribus/scribus/scpainter.cpp Sun Dec 16 18:55:10 2012
@@ -2209,10 +2209,96 @@
 	}
 }
 
-void ScPainter::drawShadePanel(const QRect &r, const QPalette &pal, bool sunken, int lineWidth)
-{
-	QColor shade = pal.dark().color();
-	QColor light = pal.light().color();
+void ScPainter::drawShadeCircle(const QRectF &re, const QColor color, bool sunken, int lineWidth)
+{
+	setStrokeMode(1);
+	double bezierCircle = 0.55228475;
+	double dx = re.width();
+	double dy = re.height();
+	double cx = dx / 2.0;
+	double cy = dy / 2.0;
+	double rb = 0.5 * (dx < dy ? dx : dy);
+	double r = rb - 0.25 * lineWidth;
+	QColor shade;
+	shade.setRgbF(color.redF() * 0.5, color.greenF() * 0.5, color.blueF() * 0.5);
+	QColor light;
+	light.setRgbF(color.redF() * 0.5 + 0.5, color.greenF() * 0.5 + 0.5, color.blueF() * 0.5 + 0.5);
+	cairo_save(m_cr);
+	translate(0, dy);
+	scale(1, -1);
+	setPen(color, lineWidth * 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+	newPath();
+	moveTo(cx + r, cy);
+	cairo_curve_to(m_cr, cx + r, cy + bezierCircle * r, cx + bezierCircle * r, cy + r, cx, cy + r);
+	cairo_curve_to(m_cr, cx - bezierCircle * r, cy + r, cx - r, cy + bezierCircle * r, cx - r, cy);
+	cairo_curve_to(m_cr, cx - r, cy - bezierCircle * r, cx - bezierCircle * r, cy - r, cx, cy - r);
+	cairo_curve_to(m_cr, cx + bezierCircle * r, cy - r, cx + r, cy - bezierCircle * r, cx + r, cy);
+	strokePath();
+	r = rb - 0.73 * lineWidth;
+	double r2 = r / 1.414213562;
+	if (sunken)
+		setPen(shade, lineWidth * 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+	else
+		setPen(light, lineWidth * 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+	newPath();
+	moveTo(cx + r2, cy + r2);
+	cairo_curve_to(m_cr, cx + (1 - bezierCircle) * r2, cy + (1 + bezierCircle) * r2, cx - (1 - bezierCircle) * r2, cy + (1 + bezierCircle) * r2, cx - r2, cy + r2);
+	cairo_curve_to(m_cr, cx - (1 + bezierCircle) * r2, cy + (1 - bezierCircle) * r2, cx - (1 + bezierCircle) * r2, cy - (1 - bezierCircle) * r2, cx - r2, cy - r2);
+	strokePath();
+	if (sunken)
+		setPen(light, lineWidth * 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+	else
+		setPen(shade, lineWidth * 0.5, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+	newPath();
+	moveTo(cx - r2, cy - r2);
+	cairo_curve_to(m_cr, cx - (1 - bezierCircle) * r2, cy - (1 + bezierCircle) * r2, cx + (1 - bezierCircle) * r2, cy - (1 + bezierCircle) * r2, cx + r2, cy - r2);
+	cairo_curve_to(m_cr, cx + (1 + bezierCircle) * r2, cy - (1 - bezierCircle) * r2, cx + (1 + bezierCircle) * r2, cy + (1 - bezierCircle) * r2, cx + r2, cy + r2);
+	strokePath();
+	cairo_restore( m_cr );
+}
+
+void ScPainter::drawShadePanel(const QRectF &r, const QColor color, bool sunken, int lineWidth)
+{
+	QColor shade;
+	QColor light;
+	if (sunken)
+	{
+		shade.setRgbF(color.redF() * 0.5, color.greenF() * 0.5, color.blueF() * 0.5);
+		light.setRgbF(color.redF() * 0.5 + 0.5, color.greenF() * 0.5 + 0.5, color.blueF() * 0.5 + 0.5);
+	}
+	else
+	{
+		light.setRgbF(color.redF() * 0.5, color.greenF() * 0.5, color.blueF() * 0.5);
+		shade.setRgbF(color.redF() * 0.5 + 0.5, color.greenF() * 0.5 + 0.5, color.blueF() * 0.5 + 0.5);
+	}
+	double x1, y1, y2, x3;
+	x1 = r.x();
+	x3 = r.x() + r.width();
+	y1 = r.y() + r.height();
+	y2 = r.y();
+	setFillMode(ScPainter::Solid);
+	newPath();
+	moveTo(x1, y1);
+	lineTo(x1, y2);
+	lineTo(x3, y2);
+	lineTo(x3 - lineWidth, lineWidth);
+	lineTo(lineWidth, lineWidth);
+	lineTo(lineWidth, y1 - lineWidth);
+	closePath();
+	setBrush(shade);
+	fillPath();
+	newPath();
+	moveTo(x1, y1);
+	lineTo(x3, y1);
+	lineTo(x3, y2);
+	lineTo(x3 - lineWidth, lineWidth);
+	lineTo(x3 - lineWidth, y1 - lineWidth);
+	lineTo(lineWidth, y1 - lineWidth);
+	closePath();
+	setBrush(light);
+	fillPath();
+
+/*
 	setStrokeMode(1);
 	setLineWidth(1.2);
 	if (sunken)
@@ -2251,5 +2337,5 @@
 		lineTo(x2--, y2--);
 		lineTo(x3--, y3++);
 		strokePath();
-	}
-}
+	} */
+}

Modified: trunk/Scribus/scribus/scpainter.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17963&path=/trunk/Scribus/scribus/scpainter.h
==============================================================================
--- trunk/Scribus/scribus/scpainter.h (original)
+++ trunk/Scribus/scribus/scpainter.h Sun Dec 16 18:55:10 2012
@@ -94,7 +94,8 @@
 	virtual void drawRect(double, double, double, double);
 	virtual void drawSharpRect(double x, double y, double w, double h);
 	virtual void drawText(QRectF area, QString text, bool filled = true, int align = 0);
-	virtual void drawShadePanel(const QRect &r, const QPalette &pal, bool sunken, int lineWidth);
+	virtual void drawShadeCircle(const QRectF &re, const QColor color, bool sunken, int lineWidth);
+	virtual void drawShadePanel(const QRectF &r, const QColor color, bool sunken, int lineWidth);
 
 	// pen + brush
 	virtual QColor pen();

Modified: trunk/Scribus/scribus/ui/outlinepalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17963&path=/trunk/Scribus/scribus/ui/outlinepalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/outlinepalette.cpp (original)
+++ trunk/Scribus/scribus/ui/outlinepalette.cpp Sun Dec 16 18:55:10 2012
@@ -310,6 +310,9 @@
  									break;
 								case Annotation::Link:
 									tipText += CommonStrings::itemSubType_PDF_LinkAnnotation;
+									break;
+								case Annotation::RadioButton:
+									tipText += CommonStrings::itemSubType_PDF_RadioButton;
  									break;
  								default:
 									tipText += CommonStrings::itemType_TextFrame;




More information about the scribus-commit mailing list