r17311 by fschmid - More work on Tables: adding line and fill shading properties to cells and borders.
scribus-commit
scribus-commit at lists.scribus.net
Fri Feb 17 21:36:51 UTC 2012
Author: fschmid
Date: Fri Feb 17 21:36:50 2012
New Revision: 17311
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17311
Log:
More work on Tables: adding line and fill shading properties to cells and borders.
Modified:
trunk/Scribus/scribus/collapsedtablepainter.cpp
trunk/Scribus/scribus/pageitem_table.cpp
trunk/Scribus/scribus/pageitem_table.h
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp
trunk/Scribus/scribus/pslib.cpp
trunk/Scribus/scribus/scribusdoc.cpp
trunk/Scribus/scribus/styles/cellstyle.attrdefs.cxx
trunk/Scribus/scribus/styles/cellstyle.cpp
trunk/Scribus/scribus/styles/tablestyle.attrdefs.cxx
trunk/Scribus/scribus/tableborder.cpp
trunk/Scribus/scribus/tableborder.h
trunk/Scribus/scribus/tablecell.h
trunk/Scribus/scribus/ui/propertiespalette_table.cpp
trunk/Scribus/scribus/ui/propertiespalette_table.h
Modified: trunk/Scribus/scribus/collapsedtablepainter.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17311&path=/trunk/Scribus/scribus/collapsedtablepainter.cpp
==============================================================================
--- trunk/Scribus/scribus/collapsedtablepainter.cpp (original)
+++ trunk/Scribus/scribus/collapsedtablepainter.cpp Fri Feb 17 21:36:50 2012
@@ -154,7 +154,7 @@
double height = table()->rowPosition(lastRow) + table()->rowHeight(lastRow) - y;
QColor color;
- table()->SetQColor(&color, colorName, 100.0);
+ table()->SetQColor(&color, colorName, table()->fillShade());
p->setBrush(color);
p->setFillMode(ScPainter::Solid);
p->setStrokeMode(ScPainter::None);
@@ -671,7 +671,7 @@
p->save();
QColor color;
- table()->SetQColor(&color, colorName, 100.0); // TODO: Support shade.
+ table()->SetQColor(&color, colorName, cell.fillShade());
p->setBrush(color);
p->setFillMode(ScPainter::Solid);
p->setStrokeMode(ScPainter::None);
@@ -708,7 +708,7 @@
lineEnd.setX(end.x() + line.width() * endOffsetFactors.x());
lineEnd.setY(end.y() + line.width() * endOffsetFactors.y());
// Set line color.
- table()->SetQColor(&lineColor, line.color(), 100.0); // TODO: Support shade.
+ table()->SetQColor(&lineColor, line.color(), line.shade());
// Draw line.
p->setPen(lineColor, line.width(), line.style(), Qt::FlatCap, Qt::MiterJoin);
p->drawLine(lineStart, lineEnd);
Modified: trunk/Scribus/scribus/pageitem_table.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17311&path=/trunk/Scribus/scribus/pageitem_table.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_table.cpp (original)
+++ trunk/Scribus/scribus/pageitem_table.cpp Fri Feb 17 21:36:50 2012
@@ -720,6 +720,23 @@
QString PageItem_Table::fillColor() const
{
return m_style.fillColor();
+}
+
+void PageItem_Table::setFillShade(const double& shade)
+{
+ m_style.setFillShade(shade);
+ emit changed();
+}
+
+void PageItem_Table::unsetFillShade()
+{
+ m_style.resetFillShade();
+ emit changed();
+}
+
+double PageItem_Table::fillShade() const
+{
+ return m_style.fillShade();
}
void PageItem_Table::setLeftBorder(const TableBorder& border)
Modified: trunk/Scribus/scribus/pageitem_table.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17311&path=/trunk/Scribus/scribus/pageitem_table.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_table.h (original)
+++ trunk/Scribus/scribus/pageitem_table.h Fri Feb 17 21:36:50 2012
@@ -385,6 +385,15 @@
/// Returns the fill color of this table.
QString fillColor() const;
+ /// Sets the fill shade of this table to @a color.
+ void setFillShade(const double& shade);
+
+ /// Unsets the fill shade of this table.
+ void unsetFillShade();
+
+ /// Returns the fill shade of this table.
+ double fillShade() const;
+
/// Sets the left border of this table to @a border.
void setLeftBorder(const TableBorder& border);
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17311&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp Fri Feb 17 21:36:50 2012
@@ -1795,6 +1795,7 @@
PageItem_Table* tableItem = item->asTable();
docu.writeStartElement("TableData");
docu.writeAttribute("FillColor", tableItem->fillColor());
+ docu.writeAttribute("FillShade", tableItem->fillShade());
//for each cell, write it to the doc
foreach (QList<TableCell> cellRow, tableItem->cellRows())
{
@@ -1811,6 +1812,7 @@
//BoundRect?
//ContentRect?
docu.writeAttribute("FillColor", cell.fillColor());
+ docu.writeAttribute("FillShade", cell.fillShade());
docu.writeAttribute("LeftPadding",cell.leftPadding());
docu.writeAttribute("RightPadding", cell.rightPadding());
docu.writeAttribute("TopPadding",cell.topPadding());
@@ -1825,6 +1827,7 @@
docu.writeAttribute("Width", tbl.width());
docu.writeAttribute("PenStyle", tbl.style());
docu.writeAttribute("Color", tbl.color());
+ docu.writeAttribute("Shade", tbl.shade());
docu.writeEndElement();
}
docu.writeEndElement();
@@ -1838,6 +1841,7 @@
docu.writeAttribute("Width", tbl.width());
docu.writeAttribute("PenStyle", tbl.style());
docu.writeAttribute("Color", tbl.color());
+ docu.writeAttribute("Shade", tbl.shade());
docu.writeEndElement();
}
docu.writeEndElement();
@@ -1851,6 +1855,7 @@
docu.writeAttribute("Width", tbl.width());
docu.writeAttribute("PenStyle", tbl.style());
docu.writeAttribute("Color", tbl.color());
+ docu.writeAttribute("Shade", tbl.shade());
docu.writeEndElement();
}
docu.writeEndElement();
@@ -1864,10 +1869,12 @@
docu.writeAttribute("Width", tbl.width());
docu.writeAttribute("PenStyle", tbl.style());
docu.writeAttribute("Color", tbl.color());
+ docu.writeAttribute("Shade", tbl.shade());
docu.writeEndElement();
}
docu.writeEndElement();
//End Cell
+ writeITEXTs(doc, docu, cell.textFrame());
docu.writeEndElement();
}
docu.writeEndElement();
Modified: trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17311&path=/trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp (original)
+++ trunk/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp Fri Feb 17 21:36:50 2012
@@ -256,12 +256,13 @@
int nBorderLines = PyList_Size(borderLinesList);
for (int i = 0; i < nBorderLines; i++) {
double width = 0.0;
+ double shade = 100.0;
int style;
char* color;
PyObject* props = PyList_GET_ITEM(borderLinesList, i);
- if (!PyArg_ParseTuple(props, "dies", &width, &style, "utf-8", &color))
- {
- PyErr_SetString(PyExc_ValueError, QObject::tr("Border lines are specified as (width,style,color) tuples", "python error").toLocal8Bit().constData());
+ if (!PyArg_ParseTuple(props, "dies|d", &width, &style, "utf-8", &color, &shade))
+ {
+ PyErr_SetString(PyExc_ValueError, QObject::tr("Border lines are specified as (width,style,color,shade) tuples", "python error").toLocal8Bit().constData());
*ok = false;
return border;
}
@@ -271,7 +272,7 @@
*ok = false;
return border;
}
- border.addBorderLine(TableBorderLine(width, static_cast<Qt::PenStyle>(style), QString::fromUtf8(color)));
+ border.addBorderLine(TableBorderLine(width, static_cast<Qt::PenStyle>(style), QString::fromUtf8(color), shade));
}
Py_DECREF(borderLinesList);
Modified: trunk/Scribus/scribus/pslib.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17311&path=/trunk/Scribus/scribus/pslib.cpp
==============================================================================
--- trunk/Scribus/scribus/pslib.cpp (original)
+++ trunk/Scribus/scribus/pslib.cpp Fri Feb 17 21:36:50 2012
@@ -2674,7 +2674,7 @@
if (colorName != CommonStrings::None)
{
PS_save();
- putColorNoDraw(colorName, 100, gcr);
+ putColorNoDraw(colorName, cell.fillShade(), gcr);
int row = cell.row();
int col = cell.column();
int lastRow = row + cell.rowSpan() - 1;
@@ -2857,6 +2857,7 @@
{
PS_save();
QPointF lineStart, lineEnd;
+ QVector<double> DashValues;
foreach (const TableBorderLine& line, border.borderLines())
{
lineStart.setX(start.x() + line.width() * startOffsetFactors.x());
@@ -2866,14 +2867,16 @@
PS_moveto(lineStart.x(), -lineStart.y());
PS_lineto(lineEnd.x(), -lineEnd.y());
PS_setlinewidth(line.width());
+ getDashArray(line.style(), qMax(line.width(), 1.0), DashValues);
+ PS_setdash(line.style(), 0, DashValues);
int h, s, v, k;
if (line.color() != CommonStrings::None)
{
- SetColor(line.color(), 100, &h, &s, &v, &k, gcr);
+ SetColor(line.color(), line.shade(), &h, &s, &v, &k, gcr);
PS_setcmykcolor_stroke(h / 255.0, s / 255.0, v / 255.0, k / 255.0);
}
PS_setcapjoin(Qt::FlatCap, Qt::MiterJoin);
- putColor(line.color(), 100, false);
+ putColor(line.color(), line.shade(), false);
}
PS_restore();
}
Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17311&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Fri Feb 17 21:36:50 2012
@@ -498,10 +498,11 @@
TableStyle defaultTableStyle;
defaultTableStyle.setName(CommonStrings::DefaultTableStyle);
defaultTableStyle.setFillColor(CommonStrings::None);
- defaultTableStyle.setLeftBorder(TableBorder(1.0, Qt::SolidLine, "Black"));
- defaultTableStyle.setRightBorder(TableBorder(1.0, Qt::SolidLine, "Black"));
- defaultTableStyle.setTopBorder(TableBorder(1.0, Qt::SolidLine, "Black"));
- defaultTableStyle.setBottomBorder(TableBorder(1.0, Qt::SolidLine, "Black"));
+ defaultTableStyle.setFillShade(100);
+ defaultTableStyle.setLeftBorder(TableBorder(1.0, Qt::SolidLine, "Black", 100));
+ defaultTableStyle.setRightBorder(TableBorder(1.0, Qt::SolidLine, "Black", 100));
+ defaultTableStyle.setTopBorder(TableBorder(1.0, Qt::SolidLine, "Black", 100));
+ defaultTableStyle.setBottomBorder(TableBorder(1.0, Qt::SolidLine, "Black", 100));
docTableStyles.create(defaultTableStyle);
docTableStyles.makeDefault(&(docTableStyles[0]));
@@ -510,10 +511,11 @@
CellStyle defaultCellStyle;
defaultCellStyle.setName(CommonStrings::DefaultCellStyle);
defaultCellStyle.setFillColor(CommonStrings::None);
- defaultCellStyle.setLeftBorder(TableBorder(1.0, Qt::SolidLine, "Black"));
- defaultCellStyle.setRightBorder(TableBorder(1.0, Qt::SolidLine, "Black"));
- defaultCellStyle.setTopBorder(TableBorder(1.0, Qt::SolidLine, "Black"));
- defaultCellStyle.setBottomBorder(TableBorder(1.0, Qt::SolidLine, "Black"));
+ defaultCellStyle.setFillShade(100);
+ defaultCellStyle.setLeftBorder(TableBorder(1.0, Qt::SolidLine, "Black", 100));
+ defaultCellStyle.setRightBorder(TableBorder(1.0, Qt::SolidLine, "Black", 100));
+ defaultCellStyle.setTopBorder(TableBorder(1.0, Qt::SolidLine, "Black", 100));
+ defaultCellStyle.setBottomBorder(TableBorder(1.0, Qt::SolidLine, "Black", 100));
defaultCellStyle.setLeftPadding(1.0);
defaultCellStyle.setRightPadding(1.0);
defaultCellStyle.setTopPadding(1.0);
Modified: trunk/Scribus/scribus/styles/cellstyle.attrdefs.cxx
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17311&path=/trunk/Scribus/scribus/styles/cellstyle.attrdefs.cxx
==============================================================================
--- trunk/Scribus/scribus/styles/cellstyle.attrdefs.cxx (original)
+++ trunk/Scribus/scribus/styles/cellstyle.attrdefs.cxx Fri Feb 17 21:36:50 2012
@@ -19,6 +19,7 @@
//Syntax: ATTRDEF( datatype, gettername, name, defaultvalue)
ATTRDEF(QString, fillColor, FillColor, CommonStrings::None)
+ATTRDEF(double, fillShade, FillShade, 100)
ATTRDEF(TableBorder, leftBorder, LeftBorder, TableBorder())
ATTRDEF(TableBorder, rightBorder, RightBorder, TableBorder())
ATTRDEF(TableBorder, topBorder, TopBorder, TableBorder())
Modified: trunk/Scribus/scribus/styles/cellstyle.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17311&path=/trunk/Scribus/scribus/styles/cellstyle.cpp
==============================================================================
--- trunk/Scribus/scribus/styles/cellstyle.cpp (original)
+++ trunk/Scribus/scribus/styles/cellstyle.cpp Fri Feb 17 21:36:50 2012
@@ -85,6 +85,7 @@
QString str("cellstyle(");
str += QString("displayName=%1,").arg(displayName());
str += QString("fillColor=%1%2,").arg(fillColor()).arg(inh_FillColor ? "(inh)" : "");
+ str += QString("fillShade=%1%2,").arg(fillShade()).arg(inh_FillShade ? "(inh)" : "");
str += QString("leftBorder=%1%2,").arg(leftBorder().asString()).arg(inh_LeftBorder ? "(inh)" : "");
str += QString("rightBorder=%1%2,").arg(rightBorder().asString()).arg(inh_RightBorder ? "(inh)" : "");
str += QString("topBorder=%1%2,").arg(topBorder().asString()).arg(inh_TopBorder ? "(inh)" : "");
Modified: trunk/Scribus/scribus/styles/tablestyle.attrdefs.cxx
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17311&path=/trunk/Scribus/scribus/styles/tablestyle.attrdefs.cxx
==============================================================================
--- trunk/Scribus/scribus/styles/tablestyle.attrdefs.cxx (original)
+++ trunk/Scribus/scribus/styles/tablestyle.attrdefs.cxx Fri Feb 17 21:36:50 2012
@@ -18,6 +18,7 @@
//Syntax: ATTRDEF( datatype, gettername, name, defaultvalue)
ATTRDEF(QString, fillColor, FillColor, CommonStrings::None)
+ATTRDEF(double, fillShade, FillShade, 100)
ATTRDEF(TableBorder, leftBorder, LeftBorder, TableBorder())
ATTRDEF(TableBorder, rightBorder, RightBorder, TableBorder())
ATTRDEF(TableBorder, topBorder, TopBorder, TableBorder())
Modified: trunk/Scribus/scribus/tableborder.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17311&path=/trunk/Scribus/scribus/tableborder.cpp
==============================================================================
--- trunk/Scribus/scribus/tableborder.cpp (original)
+++ trunk/Scribus/scribus/tableborder.cpp Fri Feb 17 21:36:50 2012
@@ -25,27 +25,29 @@
setWidth(0.0);
setStyle(Qt::SolidLine);
setColor("Black");
+ setShade(100);
}
-TableBorderLine::TableBorderLine(double width, Qt::PenStyle style, const QString& color)
+TableBorderLine::TableBorderLine(double width, Qt::PenStyle style, const QString& color, double shade)
{
setWidth(width);
setStyle(style);
setColor(color);
+ setShade(shade);
}
QString TableBorderLine::asString() const
{
- return QString("(%1,%2,%3)").arg(width()).arg(style()).arg(color());
+ return QString("(%1,%2,%3,%4)").arg(width()).arg(style()).arg(color()).arg(shade());
}
/*
* TableBorder definitions.
*/
-TableBorder::TableBorder(double width, Qt::PenStyle style, const QString& color)
+TableBorder::TableBorder(double width, Qt::PenStyle style, const QString& color, double shade)
{
- addBorderLine(TableBorderLine(width, style, color));
+ addBorderLine(TableBorderLine(width, style, color, shade));
}
double TableBorder::width() const
Modified: trunk/Scribus/scribus/tableborder.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17311&path=/trunk/Scribus/scribus/tableborder.h
==============================================================================
--- trunk/Scribus/scribus/tableborder.h (original)
+++ trunk/Scribus/scribus/tableborder.h Fri Feb 17 21:36:50 2012
@@ -25,7 +25,7 @@
TableBorderLine();
/// Creates a new table border line with @a width, @a style and @a color.
- TableBorderLine(double width, Qt::PenStyle style, const QString& color);
+ TableBorderLine(double width, Qt::PenStyle style, const QString& color, double shade);
/// Returns the width of this table border line.
double width() const { return m_width; }
@@ -45,13 +45,19 @@
/// Sets the color of this table border line to @a color.
void setColor(const QString& color) { m_color = color; }
+ /// Returns the shade of this table border line.
+ double shade() const { return m_shade; }
+
+ /// Sets the shade of this table border line to @a shade.
+ void setShade(double shade) { m_shade = shade; }
+
/// Returns a string representation of the border line.
QString asString() const;
/// Returns <code>true</code> if this table border line is equal to @a other.
bool operator==(const TableBorderLine& other) const
{
- return width() == other.width() && color() == other.color() && style() == other.style();
+ return width() == other.width() && color() == other.color() && style() == other.style() && shade() == other.shade();
}
/// Returns <code>true</code> if this table border line is not equal to @a other.
@@ -67,6 +73,8 @@
Qt::PenStyle m_style;
/// The color of the table border line.
QString m_color;
+ /// Ths shade of the table border line
+ double m_shade;
};
Q_DECLARE_TYPEINFO(TableBorderLine, Q_MOVABLE_TYPE);
@@ -82,7 +90,7 @@
TableBorder() {}
/// Creates a new table border with a single border line with @a width, @a style and @a color.
- TableBorder(double width, Qt::PenStyle style, const QString& color);
+ TableBorder(double width, Qt::PenStyle style, const QString& color, double shade);
/// Returns the width of the first table border line, or 0.0 if this is a null border.
double width() const;
Modified: trunk/Scribus/scribus/tablecell.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17311&path=/trunk/Scribus/scribus/tablecell.h
==============================================================================
--- trunk/Scribus/scribus/tablecell.h (original)
+++ trunk/Scribus/scribus/tablecell.h Fri Feb 17 21:36:50 2012
@@ -141,6 +141,12 @@
/// Returns the fill color of this cell.
QString fillColor() const { return d->style.fillColor(); }
+ /// Sets the fill color of this cell to @a color.
+ void setFillColor(const double& shade) { d->style.setFillShade(shade); }
+
+ /// Returns the fill color of this cell.
+ double fillShade() const { return d->style.fillShade(); }
+
/// Sets the left border of this cell to @a border.
void setLeftBorder(const TableBorder& border);
Modified: trunk/Scribus/scribus/ui/propertiespalette_table.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17311&path=/trunk/Scribus/scribus/ui/propertiespalette_table.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_table.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_table.cpp Fri Feb 17 21:36:50 2012
@@ -230,6 +230,7 @@
fillShadeLabel->setEnabled(true);
// Fill in values.
setCurrentComboItem(fillColor, table->fillColor());
+ fillShade->setValue(table->fillShade());
}
else
{
@@ -283,6 +284,7 @@
borderLineWidth->showValue(line.width());
setCurrentComboItem(borderLineColor, line.color());
borderLineStyle->setCurrentIndex(static_cast<int>(line.style()) - 1);
+ borderLineShade->setValue(line.shade());
}
}
@@ -318,6 +320,17 @@
updateBorderLineListItem();
}
+void PropertiesPalette_Table::on_borderLineShade_valueChanged(int shade)
+{
+ int index = borderLineList->currentRow();
+ TableBorderLine borderLine = m_currentBorder.borderLines().at(index);
+ borderLine.setShade(shade);
+ m_currentBorder.replaceBorderLine(index, borderLine);
+
+ updateBorders();
+ updateBorderLineListItem();
+}
+
void PropertiesPalette_Table::on_borderLineColor_activated(const QString& colorName)
{
int index = borderLineList->currentRow();
@@ -347,7 +360,18 @@
PageItem_Table* table = m_item->asTable();
table->setFillColor(colorName);
-
+ table->setFillShade(fillShade->value());
+ table->update();
+}
+
+void PropertiesPalette_Table::on_fillShade_valueChanged(int shade)
+{
+ if (!m_item || !m_item->isTable())
+ return;
+
+ PageItem_Table* table = m_item->asTable();
+ table->setFillColor(fillColor->currentColor());
+ table->setFillShade(shade);
table->update();
}
Modified: trunk/Scribus/scribus/ui/propertiespalette_table.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17311&path=/trunk/Scribus/scribus/ui/propertiespalette_table.h
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_table.h (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_table.h Fri Feb 17 21:36:50 2012
@@ -67,7 +67,8 @@
void on_addBorderLineButton_clicked();
/// Handles removing of a border line.
void on_removeBorderLineButton_clicked();
- /// Handles border line width changes.
+ /// Handles border line shade changes.
+ void on_borderLineShade_valueChanged(int shade);
/// Handles border line width changes.
void on_borderLineWidth_valueChanged(double width);
/// Handles border line color changes.
@@ -77,6 +78,8 @@
/// Handles table fill color changes.
void on_fillColor_activated(const QString& colorName);
+ /// Handles table fill shade changes.
+ void on_fillShade_valueChanged(int shade);
private:
/// This enum represents three states. Used for three-state logic.
More information about the scribus-commit
mailing list