GradientPreview::GradientPreview(QWidget *pa) : QFrame(pa) { setFrameShape( QFrame::Panel ); setFrameShadow( QFrame::Sunken ); setLineWidth( 2 ); setMinimumSize(QSize(200, 70)); setMaximumSize(QSize(3000, 70)); setMouseTracking(true); setFocusPolicy(Qt::ClickFocus); Mpressed = false; outside = true; onlyselect = true; isEditable = true; fill_gradient = VGradient(VGradient::linear); fill_gradient.clearStops(); QColor color; color = QColor(255,255,255); fill_gradient.addStop( color, 0.0, 0.5, 1.0 ); color = QColor(0,0,0); fill_gradient.addStop( color, 1.0, 0.5, 1.0 ); QList<VColorStop*> cstops = fill_gradient.colorStops(); StopM.clear(); ActStop = 0; for (uint a = 0; a < fill_gradient.Stops(); ++a) { int center = qRound(cstops.at(a)->rampPoint * (width()-20))+10; StopM.append(center); } }
void ScrPainter::startGraphics(double width, double height) { CurrColorFill = "Black"; CurrFillShade = 100.0; CurrColorStroke = "Black"; CurrStrokeShade = 100.0; CurrStrokeTrans = 0.0; CurrFillTrans = 0.0; Coords.resize(0); Coords.svgInit(); LineW = 1.0; lineJoin = Qt::MiterJoin; lineEnd = Qt::FlatCap; fillrule = true; gradientAngle = 0.0; isGradient = false; fillSet = false; strokeSet = false; currentGradient = VGradient(VGradient::linear); currentGradient.clearStops(); currentGradient.setRepeatMethod( VGradient::none ); dashArray.clear(); if (flags & LoadSavePlugin::lfCreateDoc) { m_Doc->setPage(72 * width, 72 * height, 0, 0, 0, 0, 0, 0, false, false); if (width > height) m_Doc->setPageOrientation(1); else m_Doc->setPageOrientation(0); m_Doc->setPageSize("Custom"); m_Doc->changePageMargins(0, 0, 0, 0, 72 * height, 72 * width, 72 * height, 72 * width, m_Doc->pageOrientation(), m_Doc->pageSize(), m_Doc->currentPage()->pageNr(), 0); } firstLayer = true; }
void ScrPainter::setBrush(const libwpg::WPGBrush& brush) { ScColor tmp; ColorList::Iterator it; CurrColorFill = "Black"; CurrFillShade = 100.0; int Rc, Gc, Bc; if(brush.style == libwpg::WPGBrush::Solid) { Rc = brush.foreColor.red; Gc = brush.foreColor.green; Bc = brush.foreColor.blue; tmp.setColorRGB(Rc, Gc, Bc); tmp.setSpotColor(false); tmp.setRegistrationColor(false); QString newColorName = "FromWPG"+tmp.name(); QString fNam = m_Doc->PageColors.tryAddColor(newColorName, tmp); if (fNam == newColorName) importedColors.append(newColorName); CurrColorFill = fNam; CurrFillTrans = brush.foreColor.alpha / 255.0; } else if (brush.style == libwpg::WPGBrush::Gradient) { gradientAngle = brush.gradient.angle(); isGradient = true; currentGradient = VGradient(VGradient::linear); currentGradient.clearStops(); for(unsigned c = 0; c < brush.gradient.count(); c++) { QString currStopColor = CommonStrings::None; Rc = brush.gradient.stopColor(c).red; Gc = brush.gradient.stopColor(c).green; Bc = brush.gradient.stopColor(c).blue; tmp.setColorRGB(Rc, Gc, Bc); tmp.setSpotColor(false); tmp.setRegistrationColor(false); QString newColorName = "FromWPG"+tmp.name(); QString fNam = m_Doc->PageColors.tryAddColor(newColorName, tmp); if (fNam == newColorName) importedColors.append(newColorName); currStopColor = fNam; const ScColor& gradC = m_Doc->PageColors[currStopColor]; double pos = qBound(0.0, fabs(brush.gradient.stopOffset(c)), 1.0); currentGradient.addStop( ScColorEngine::getRGBColor(gradC, m_Doc), pos, 0.5, 1.0, currStopColor, 100 ); } } else if (brush.style == libwpg::WPGBrush::NoBrush) CurrColorFill = CommonStrings::None; fillSet = true; }
void gradientManagerDialog::addGradient() { VGradient fill_gradient = VGradient(VGradient::linear); fill_gradient.clearStops(); fill_gradient.addStop(QColor(Qt::black), 0.0, 0.5, 1.0, "Black", 100); fill_gradient.addStop(QColor(Qt::white), 1.0, 0.5, 1.0, "White", 100); gradientEditDialog *dia = new gradientEditDialog(this, tr("New Gradient"), fill_gradient, m_colorList, m_doc, &dialogGradients, true); if (dia->exec()) { dialogGradients.insert(dia->name(), dia->gradient()); updateGradientList(); } delete dia; }