int UtcDaliTextInputGetMarkupText(void) { ToolkitTestApplication application; tet_infoline("Testing retrieval of Markup text after style set"); const std::string markup = "<i>Text with italic style</i>" ; const std::string teststring = "Text with italic style"; TextInput textInput = TextInput::New(); tet_infoline("Set initial text"); textInput.SetInitialText( teststring ); tet_infoline("Check initial text"); DALI_TEST_EQUALS( teststring,textInput.GetText(), TEST_LOCATION); // Get text which should be empty TextStyle style; style.SetItalics( true ); tet_infoline("Apply style to TextInput"); textInput.ApplyStyleToAll( style ); tet_infoline("Retreive Markup Text"); const std::string retreivedMarkupString = textInput.GetMarkupText(); tet_infoline("Test Retreived text and Markup text match"); DALI_TEST_EQUALS( retreivedMarkupString , retreivedMarkupString, TEST_LOCATION); END_TEST; }
void TextStyleDialog::newClicked() { QString s = QInputDialog::getText(this, tr("MuseScore: Read Style Name"), tr("Text Style Name:")); if (s.isEmpty()) return; for (;;) { bool notFound = true; for (int i = 0; i < styles.size(); ++i) { const TextStyle& style = styles.at(i); if (style.name() == s) { notFound = false; break; } } if (!notFound) { s = QInputDialog::getText(this, tr("MuseScore: Read Style Name"), QString(tr("'%1' does already exist,\nplease choose a different name:")).arg(s) ); if (s.isEmpty()) return; } else break; } textNames->addItem(s); TextStyle newStyle; newStyle.setName(s); styles.append(newStyle); }
void TextField2::render(float dt) { if (!mVisible || mFont == NULL || !mFont->isLoaded()) { return; } mCurrentLine = 0; preRender(dt); mFont->getAsset()->getTexture()->bindTexture(); glBegin(GL_QUADS); while (mCurrentNode.get() != NULL) { if (mNewLineDirty) { Node::NodeHitboxList &list = mCurrentNode->getHitboxes(); list.clear(); Handle<NodeHitbox> hitbox(new NodeHitbox(mCurrentNode)); mTextHitboxes->addChild(hitbox.get()); hitbox->setPosition(mCurrXpos, mCurrYpos - mTextHitboxes->getPositionY()); hitbox->setHeight(mFont->getCharHeight()); hitbox->addEventListener(MOUSE_UP, this); list.push_back(hitbox); } TextStyle currentStyle = mCurrentNode->getTextStyle(); GfxEngine::getEngine()->popColourStack(); if (currentStyle.hasColour()) { GfxEngine::getEngine()->pushColourStack(currentStyle.getColour()); } else { if (mGfxComponent) { GfxEngine::getEngine()->pushColourStack(mGfxComponent->getColour()); } else { GfxEngine::getEngine()->pushColourStack(Colour::WHITE); } } GfxEngine::getEngine()->applyColourStack(); renderText(mCurrentNode->getText()); mCurrentNode = mCurrentNode->nextSibling(); } glEnd(); mScrollbar->setMaxValue(getTotalNumLines() - mDisplayNumLines - 1); mNewLineDirty = false; for (ChildList::iterator iter = mChildren.begin(); iter != mChildren.end(); ++iter) { if (mGfxComponent) { mGfxComponent->getColour().applyColour(); } (*iter)->render(dt); } postRender(dt); }
void TextStyleDialog::saveStyle(int n) { int listIdx = textNames->item(n)->data(Qt::UserRole).toInt(); TextStyle st = tp->textStyle(); st._hidden = styles.at(listIdx).hidden(); st.setName(styles.at(listIdx).name()); // set data members not set by TextProp::textStyle() styles[listIdx] = st; // store style into local style list }
/* StyleSet::getStyleBackground * Returns the background colour of [style], or the default style's * background colour if it is not set *******************************************************************/ rgba_t StyleSet::getStyleBackground(string style) { TextStyle* s = getStyle(style); if (s && s->hasBackground()) return s->getBackground(); else return ts_default.getBackground(); }
void TextStyleDialog::saveStyle(int n) { TextStyle st = tp->textStyle(); // set data members not set by TextProp::textStyle() st.setName(styles[n].name()); // TextProp::textStyle() now deals with sizeIsSpatiumDependent // Following statement defeats additions to TextProp::textStyle() // st.setSizeIsSpatiumDependent(styles[n].sizeIsSpatiumDependent()); styles[n] = st; }
void convertTextStyleToJSON(llvm::raw_string_ostream &Stream, llvm::StringRef StyleName, TextStyle const &Style) { Stream << '"' << StyleName << '"' << ": {" << "\"Foreground\": \"" << Style.GetForeground().GetAsString().ToStdString() << "\"," << "\"Background\": \"" << Style.GetBackground().GetAsString().ToStdString() << "\"" << "}"; };
int main() { string orig = "<font color=\"$style\">$text</font>"; string expected = "<font color=\"green\">foo</font>"; string transformed; TextStyle textStyle1(orig); transformed = textStyle1.output("foo", "green"); cout << "orig: " << textStyle1.toString() << endl; cout << "transformed: " << transformed << endl; assertEquals(true, textStyle1.containsStyleVar()); assertEquals(expected, transformed); orig = "<b>$text</b>"; expected = "<b>foo</b>"; textStyle1 = TextStyle(orig); transformed = textStyle1.output("foo", "green"); cout << "orig: " << textStyle1.toString() << endl; cout << "transformed: " << transformed << endl; assertEquals(false, textStyle1.containsStyleVar()); assertEquals(expected, transformed); TextStyle inner("<i>$text</i>"); TextStyle composed = textStyle1.compose(inner); transformed = composed.output("foo"); cout << "orig:" << composed.toString() << endl; cout << "transformed: " << transformed << endl; assertEquals("<b><i>foo</i></b>", transformed); expected = "(\\foo)"; textStyle1 = TextStyle(); transformed = textStyle1.output("(\\foo)", "green"); cout << "orig: " << textStyle1.toString() << endl; cout << "transformed: " << transformed << endl; assertEquals(expected, transformed); cout << "test_textstyle: SUCCESS!" << endl; return 0; }
void cTextField::set_ip(location clickLoc, int cTextField::* insertionPoint) { TextStyle style; style.font = FONT_PLAIN; style.pointSize = 12; style.colour = sf::Color::Black; style.lineHeight = 16; size_t foundSnippet = snippets.size(); // Find snippet clicked. for(size_t i = 0; i < snippets.size(); i++) { short h, w = string_length(snippets[i].text, style, &h); rectangle snipRect; snipRect.top = snippets[i].at.y; snipRect.left = snippets[i].at.x; snipRect.width() = w; snipRect.height() = h; if(snipRect.contains(clickLoc)) { foundSnippet = i; break; } } if(foundSnippet < snippets.size()) { sf::Text snippet; style.applyTo(snippet); snippet.setString(snippets[foundSnippet].text); snippet.setPosition(snippets[foundSnippet].at); size_t charClicked = snippets[foundSnippet].text.length(); // Find character clicked. By now we know the Y position is okay, so just check X. if(clickLoc.x <= snippet.findCharacterPos(0).x) charClicked = 0; else for(size_t i = 0; i < snippets[foundSnippet].text.length(); i++) { if(clickLoc.x > snippet.findCharacterPos(i).x) charClicked = i; else break; } if(charClicked < snippets[foundSnippet].text.length()) { size_t pre_ip = std::accumulate(snippets.begin(), snippets.begin() + foundSnippet, 0, [](size_t sum, snippet_t& next) -> size_t { return sum + next.text.length(); }); int left = snippet.findCharacterPos(charClicked).x; int right; if(charClicked + 1 == snippets[foundSnippet].text.length()) right = rectangle(snippet.getGlobalBounds()).right; else right = snippet.findCharacterPos(charClicked + 1).x; left = clickLoc.x - left; right -= clickLoc.x; if(left < right) this->*insertionPoint = pre_ip + charClicked; else this->*insertionPoint = pre_ip + charClicked + 1; } } }
void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const TextStyle& style, const FloatPoint& point, int from, int to) const { // This glyph buffer holds our glyphs + advances + font data for each glyph. GlyphBuffer glyphBuffer; float startX = point.x(); UniscribeController controller(this, run, style); controller.advance(from); float beforeWidth = controller.runWidthSoFar(); controller.advance(to, &glyphBuffer); // We couldn't generate any glyphs for the run. Give up. if (glyphBuffer.isEmpty()) return; float afterWidth = controller.runWidthSoFar(); if (style.rtl()) { controller.advance(run.length()); startX += controller.runWidthSoFar() - afterWidth; } else startX += beforeWidth; // Draw the glyph buffer now at the starting point returned in startX. FloatPoint startPoint(startX, point.y()); drawGlyphBuffer(context, glyphBuffer, run, style, startPoint); }
float Font::floatWidthForSimpleText(const TextRun& run, const TextStyle& style, float* startPosition, GlyphBuffer* glyphBuffer) const { int text_width; // FIXME: Process normal, bold, italic styles // if (m_fontDescription.italic()) { // if (m_fontDescription.bold()) { // // Bold && italic // TTF_SetFontStyle(d->m_ttfFont, TTF_STYLE_BOLD | TTF_STYLE_ITALIC); // } else { // // Only italic // TTF_SetFontStyle(d->m_ttfFont, TTF_STYLE_ITALIC); // } // } else if (m_fontDescription.bold()) { // // Only bold // TTF_SetFontStyle(d->m_ttfFont, TTF_STYLE_BOLD); // } else // TTF_SetFontStyle(d->m_ttfFont, TTF_STYLE_NORMAL); int wordSize = run.length() - run.from(); UChar word[wordSize]; copyTextRunTo(run, word); DFBCHECK(d->m_ttfFont->GetStringWidth(d->m_ttfFont, word, -1, &text_width)); if (startPosition) { if (style.ltr()) *startPosition = text_width ; else *startPosition = text_width; } return static_cast<float> (text_width); }
void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const TextStyle& style, const FloatPoint& point, int from, int to) const { cairo_t* cr = context->platformContext(); cairo_save(cr); PangoLayout* layout = pango_cairo_create_layout(cr); gchar* utf8 = convertUniCharToUTF8(run.characters(), run.length(), from, run.length()); pango_layout_set_text(layout, utf8, -1); setPangoAttributes(this, run, layout, style.rtl()); // Set the text color to use for drawing. float red, green, blue, alpha; Color penColor = context->fillColor(); penColor.getRGBA(red, green, blue, alpha); cairo_set_source_rgba(cr, red, green, blue, alpha); cairo_move_to(cr, point.x(), point.y()); PangoLayoutLine* layoutLine = pango_layout_get_line(layout, 0); pango_cairo_show_layout_line(cr, layoutLine); g_free(utf8); g_object_unref(layout); cairo_restore(cr); }
static float size_font(const ParaStyle& para,const TextStyle& font,float w,float h) { auto size=font.size(); switch(font.textSizeMode()) { case TextSizeMode::ABSOLUTE: return size; case TextSizeMode::FONT: return size; case TextSizeMode::BOX: if(para.textSizeMode()==TextSizeMode::FONT) {ERROR("Inconsistent size constraint");} return size_box(para,font,w,h)*size; case TextSizeMode::PAGE: return size*h; } return size; }
void TextStyleDialog::newClicked() { QString s = QInputDialog::getText(this, tr("MuseScore: Read Style Name"), tr("Text Style Name:")); if (s.isEmpty()) return; for (;;) { bool notFound = true; for (int i = 0; i < styles.size(); ++i) { const TextStyle& style = styles.at(i); if (style.name() == s) { notFound = false; break; } } if (!notFound) { s = QInputDialog::getText(this, tr("MuseScore: Read Style Name"), QString(tr("'%1' does already exist,\nplease choose a different name:")).arg(s) ); if (s.isEmpty()) return; } else break; } // // use current selected style as template // QString name = textNames->currentItem()->text(); TextStyle newStyle = cs->textStyle(name); newStyle.setName(s); int count = textNames->count(); int listIdx = styles.count(); styles.append(newStyle); textNames->addItem(s); textNames->item(count)->setData(Qt::UserRole, listIdx); textNames->setCurrentRow(count); cs->setDirty(true); mscore->endCmd(); }
FloatRect Font::selectionRectForComplexText(const TextRun& run, const TextStyle& style, const IntPoint& point, int h, int from, int to) const { FloatRect rect; float tw; PangoLayout* layout = getDefaultPangoLayout(run); setPangoAttributes(this, run, layout, style.rtl()); float beforeWidth = getWidth (layout, run, 0, from); float afterWidth = getWidth (layout, run, 0, to); if (style.rtl()) { float totalWidth = getWidth (layout, run, 0, run.length()); tw = totalWidth; rect = FloatRect(point.x() + floorf(totalWidth - afterWidth), point.y(), roundf(totalWidth - beforeWidth) - floorf(totalWidth - afterWidth), h); } else rect = FloatRect(point.x() + floorf(beforeWidth), point.y(), roundf(afterWidth) - floorf(beforeWidth), h); g_object_unref(layout); return rect; }
void Page::drawStyledHeaderFooter(QPainter* p, int area, const QPointF& pt, const QString& ss) const { QString s = replaceTextMacros(ss); if (s.isEmpty()) return; int textStyle = TEXT_STYLE_FOOTER; int flags = Qt::TextDontClip; switch(area) { case 0: flags |= Qt::AlignLeft | Qt::AlignTop; textStyle = TEXT_STYLE_HEADER; break; case 1: flags |= Qt::AlignHCenter | Qt::AlignTop; textStyle = TEXT_STYLE_HEADER; break; case 2: flags |= Qt::AlignRight | Qt::AlignTop; textStyle = TEXT_STYLE_HEADER; break; case 3: flags |= Qt::AlignLeft | Qt::AlignBottom; break; case 4: flags |= Qt::AlignHCenter | Qt::AlignBottom; break; case 5: flags |= Qt::AlignRight | Qt::AlignBottom; break; } TextStyle ts = score()->textStyle(textStyle); p->setFont(ts.fontPx(spatium())); QRectF r(pt.x(), pt.y(), width() - lm() - rm(), height() - tm() - bm()); p->drawText(r, flags, s); }
int Font::offsetForPositionForComplexText(const TextRun& run, const TextStyle& style, int x, bool includePartialGlyphs) const { PangoLayout* layout = getDefaultPangoLayout(run); setPangoAttributes(this, run, layout, style.rtl()); gchar* utf8 = convertUniCharToUTF8(run.characters(), run.length(), 0, run.length()); pango_layout_set_text(layout, utf8, -1); int index, trailing; pango_layout_xy_to_index(layout, x * PANGO_SCALE, 1, &index, &trailing); glong offset = g_utf8_pointer_to_offset(utf8, utf8 + index); g_object_unref(layout); g_free(utf8); return offset; }
FloatRect Font::selectionRectForComplexText(const TextRun& run, const TextStyle& style, const IntPoint& point, int h, int from, int to) const { UniscribeController it(this, run, style); it.advance(from); float beforeWidth = it.runWidthSoFar(); it.advance(to); float afterWidth = it.runWidthSoFar(); // Using roundf() rather than ceilf() for the right edge as a compromise to ensure correct caret positioning if (style.rtl()) { it.advance(run.length()); float totalWidth = it.runWidthSoFar(); return FloatRect(point.x() + floorf(totalWidth - afterWidth), point.y(), roundf(totalWidth - beforeWidth) - floorf(totalWidth - afterWidth), h); } return FloatRect(point.x() + floorf(beforeWidth), point.y(), roundf(afterWidth) - floorf(beforeWidth), h); }
static float size_box(const ParaStyle& para,const TextStyle& font,float w,float h) { auto size=para.size(); switch(para.textSizeMode()) { case TextSizeMode::ABSOLUTE: return size; case TextSizeMode::FONT: if(font.textSizeMode()==TextSizeMode::BOX) {ERROR("Inconsistent size constraint");} return size_font(para,font,w,h)*size; case TextSizeMode::BOX: return size; case TextSizeMode::PAGE: return para.sizeDimension()==ParaStyle::SizeDimension::HEIGHT? size*h:size*w; } return size; }
float Font::floatWidthForComplexText(const TextRun& run, const TextStyle& style) const { if (run.length() == 0) return 0.0f; PangoLayout* layout = getDefaultPangoLayout(run); setPangoAttributes(this, run, layout, style.rtl()); gchar* utf8 = convertUniCharToUTF8(run.characters(), run.length(), 0, run.length()); pango_layout_set_text(layout, utf8, -1); g_free(utf8); int layoutWidth; pango_layout_get_size(layout, &layoutWidth, 0); float width = (float)layoutWidth / (double)PANGO_SCALE; g_object_unref(layout); return width; }
void TextProp::setTextStyle(const TextStyle& s) { ts = s; fontBold->setChecked(s.bold()); fontItalic->setChecked(s.italic()); fontUnderline->setChecked(s.underline()); fontSize->setValue(s.size()); color->setColor(s.foregroundColor()); systemFlag->setChecked(s.systemFlag()); Align a = s.align(); if (a & AlignmentFlags::HCENTER) alignHCenter->setChecked(true); else if (a & AlignmentFlags::RIGHT) alignRight->setChecked(true); else alignLeft->setChecked(true); if (a & AlignmentFlags::VCENTER) alignVCenter->setChecked(true); else if (a & AlignmentFlags::BOTTOM) alignBottom->setChecked(true); else if (a & AlignmentFlags::BASELINE) alignBaseline->setChecked(true); else alignTop->setChecked(true); if (s.offsetType() == OffsetType::ABS) { xOffset->setValue(s.offset().x() * INCH); yOffset->setValue(s.offset().y() * INCH); mmUnit->setChecked(true); curUnit = 0; } else if (s.offsetType() == OffsetType::SPATIUM) { xOffset->setValue(s.offset().x()); yOffset->setValue(s.offset().y()); spatiumUnit->setChecked(true); curUnit = 1; } QFont f(s.family()); f.setPixelSize(lrint(s.size())); f.setItalic(s.italic()); f.setUnderline(s.underline()); f.setBold(s.bold()); fontSelect->setCurrentFont(f); sizeIsSpatiumDependent->setChecked(s.sizeIsSpatiumDependent()); frameColor->setColor(s.frameColor()); bgColor->setColor(s.backgroundColor()); frameWidth->setValue(s.frameWidth().val()); frame->setChecked(s.hasFrame()); paddingWidth->setValue(s.paddingWidth().val()); frameRound->setValue(s.frameRound()); circleButton->setChecked(s.circle()); boxButton->setChecked(!s.circle()); }
TextStyle TextProp::textStyle() const { TextStyle s; if (curUnit == 0) s.setOffsetType(OFFSET_ABS); else if (curUnit == 1) s.setOffsetType(OFFSET_SPATIUM); s.setBold(fontBold->isChecked()); s.setItalic(fontItalic->isChecked()); s.setUnderline(fontUnderline->isChecked()); s.setSize(fontSize->value()); QFont f = fontSelect->currentFont(); s.setFamily(f.family()); s.setXoff(xOffset->value() / ((s.offsetType() == OFFSET_ABS) ? INCH : 1.0)); s.setYoff(yOffset->value() / ((s.offsetType() == OFFSET_ABS) ? INCH : 1.0)); s.setRxoff(rxOffset->value()); s.setRyoff(ryOffset->value()); s.setFrameColor(frameColor->color()); s.setBackgroundColor(bgColor->color()); s.setFrameWidth(frameWidth->value()); s.setPaddingWidth(paddingWidth->value()); s.setCircle(circleButton->isChecked()); s.setFrameRound(frameRound->value()); s.setHasFrame(frame->isChecked()); s.setSystemFlag(systemFlag->isChecked()); s.setForegroundColor(color->color()); s.setSizeIsSpatiumDependent(sizeIsSpatiumDependent->isChecked()); Align a = 0; if (alignHCenter->isChecked()) a |= ALIGN_HCENTER; else if (alignRight->isChecked()) a |= ALIGN_RIGHT; if (alignVCenter->isChecked()) a |= ALIGN_VCENTER; else if (alignBottom->isChecked()) a |= ALIGN_BOTTOM; else if (alignBaseline->isChecked()) a |= ALIGN_BASELINE; s.setAlign(a); return s; }
void Page::draw(QPainter* painter) const { if (score()->layoutMode() != LayoutPage) return; // // draw header/footer // QTextDocument d; d.setDocumentMargin(0.0); d.setUseDesignMetrics(true); int n = no() + 1 + _score->pageNumberOffset(); d.setTextWidth(score()->loWidth() - lm() - rm()); QPointF o1(lm(), tm()); painter->translate(o1); painter->setPen(curColor()); QString s1, s2, s3; if (_score->styleB(ST_showHeader) && (no() || _score->styleB(ST_headerFirstPage))) { TextStyle ts = score()->textStyle(TEXT_STYLE_HEADER); QPointF o(ts.offset(spatium())); bool odd = (n & 1) || !_score->styleB(ST_headerOddEven); if (odd) { o.setX(-o.x()); s1 = _score->styleSt(ST_oddHeaderL); s2 = _score->styleSt(ST_oddHeaderC); s3 = _score->styleSt(ST_oddHeaderR); } else { s1 = _score->styleSt(ST_evenHeaderL); s2 = _score->styleSt(ST_evenHeaderC); s3 = _score->styleSt(ST_evenHeaderR); } if (_score->styleB(ST_headerStyled)) { drawStyledHeaderFooter(painter, 0, o, s1); drawStyledHeaderFooter(painter, 1, o, s2); drawStyledHeaderFooter(painter, 2, o, s3); } else { d.setDefaultFont(ts.font(1.0)); d.setTextWidth(_score->loWidth() - lm() - rm() - (2.0 * o.x())); QAbstractTextDocumentLayout::PaintContext c; c.cursorPosition = -1; c.palette.setColor(QPalette::Text, ts.foregroundColor()); painter->translate(o); QString s = _score->styleSt(odd ? ST_oddHeaderL : ST_evenHeaderL); if (!s.isEmpty()) { d.setHtml(replaceTextMacros(s)); d.documentLayout()->draw(painter, c); } s = replaceTextMacros(_score->styleSt(odd ? ST_oddHeaderC : ST_evenHeaderC)); if (!s.isEmpty()) { d.setHtml(s); d.documentLayout()->draw(painter, c); } s = replaceTextMacros(_score->styleSt(odd ? ST_oddHeaderR : ST_evenHeaderR)); if (!s.isEmpty()) { d.setHtml(s); d.documentLayout()->draw(painter, c); } painter->translate(-o); } } if (_score->styleB(ST_showFooter) && (no() || _score->styleB(ST_footerFirstPage))) { TextStyle ts = score()->textStyle(TEXT_STYLE_FOOTER); QPointF o(ts.offset(spatium())); bool odd = (n & 1) || !_score->styleB(ST_footerOddEven); if (odd) { o.setX(-o.x()); s1 = _score->styleSt(ST_oddFooterL); s2 = _score->styleSt(ST_oddFooterC); s3 = _score->styleSt(ST_oddFooterR); } else { s1 = _score->styleSt(ST_evenFooterL); s2 = _score->styleSt(ST_evenFooterC); s3 = _score->styleSt(ST_evenFooterR); } if (_score->styleB(ST_footerStyled)) { drawStyledHeaderFooter(painter, 3, o, s1); drawStyledHeaderFooter(painter, 4, o, s2); drawStyledHeaderFooter(painter, 5, o, s3); } else { qreal w = _score->loWidth() - lm() - rm() - (2.0 * o.x()); o = QPointF(0.0, _score->loHeight() - (tm() + bm())); QAbstractTextDocumentLayout::PaintContext c; c.cursorPosition = -1; c.palette.setColor(QPalette::Text, ts.foregroundColor()); painter->translate(o); qreal h1, h2, h3; QTextDocument d1, d2, d3; QFont f; if (!s1.isEmpty()) { d1.setDocumentMargin(0.0); d1.setUseDesignMetrics(true); s1 = replaceTextMacros(s1); d1.setTextWidth(w); d1.setHtml(s1); h1 = d1.documentLayout()->documentSize().height(); } else h1 = 0.0; if (!s2.isEmpty()) { d2.setDocumentMargin(0.0); d2.setUseDesignMetrics(true); s2 = replaceTextMacros(s2); d2.setTextWidth(w); d2.setHtml(s2); h2 = d2.documentLayout()->documentSize().height(); } else h2 = 0.0; if (!s3.isEmpty()) { d3.setDocumentMargin(0.0); d3.setUseDesignMetrics(true); s3 = replaceTextMacros(s3); d3.setTextWidth(w); d3.setHtml(s3); h3 = d3.documentLayout()->documentSize().height(); } else h3 = 0.0; qreal h = qMax(h1, h2); h = qMax(h, h3); QPointF pos(0.0, -h); painter->translate(pos); if (!s1.isEmpty()) d1.documentLayout()->draw(painter, c); if (!s2.isEmpty()) d2.documentLayout()->draw(painter, c); if (!s3.isEmpty()) d3.documentLayout()->draw(painter, c); painter->translate(-(o + pos)); } } painter->translate(-o1); }
void SVGImage::text (const Text& text) { using namespace std; TextStyle ts; StyleType tts = getCorrectTextStyle(&ts,text); if( tts == CLEAR ) { comment("Text with clear font ignored:%s",text.getString().c_str()); return; } Color tc = ts.getColor(); int angle = text.getAngle(); ostr << tab; ostr << "<text x=\"" << text.x << "\" y=\"" << ((ll)?(canvasHeight-text.y):text.y) << "\""; //For the moment...to correct the transform if ( ll ) { ostr << " transform=\"scale(1,-1) translate(0,-" << canvasHeight << ")"; if ( angle ) ostr << " rotate(" << setbase(10) << -angle << "," << text.x << "," << ((ll)?(canvasHeight-text.y):text.y) << ")"; ostr << "\""; } else if ( angle ) ostr << " transform=\"rotate(" << setbase(10) << -angle << "," << text.x << "," << ((ll)?(canvasHeight-text.y):text.y) << ")\""; stringstream tmp; if(tc!=Color::BLACK) { tmp.fill('0'); tmp << "fill:#" << hex << setw(6) << tc.getRGB() << ";"; } if(ts.getPointSize()!=12) tmp << "font-size:" << ts.getPointSize() << "pt;"; if(!ts.isMonospace()) tmp << "font-family:" << (ts.isSerif()?"serif":(ts.isSansSerif()?"sans-serif":"")) << ";"; //<< (ts.isMonospace()?"monospace":(ts.isSerif()?"serif":(ts.isSansSerif()?"sans-serif":""))) << ";" tmp << (ts.isBold()?"font-weight:bold;":"") << (ts.isItalic()?"font-style:italic;":"") << (ts.isUnderline()?"text-decoration:underline;":"") << (ts.isStrike()?"text-decoration:line-through;":""); if(!text.isLeft()) tmp << "text-anchor:" << (text.isCenter()?"middle":"end") << ";"; // << (text.isCenter()?"middle":(text.isLeft()?"start":"end")) << ";" string t = tmp.str(); if(t.size()!=0) ostr << endl << tab << " style=\"" << t << "\""; // Close first xml tag ostr << ">" << endl; ostr << tab << text.getString() << endl; ostr << tab <<"</text>" << endl; }
void SeriesList::drawLegendSegment(Frame& frame, double pointsize, unsigned int begin, unsigned int n) { // If we aren't drawing anything, don't bother with all the effort :) if(n == 0) return; // Spacer is the number of points between the drawn segment and the text // of the label as well as the added number of spacing between each // series in the list double spacer = 5; // Test to see if we are dealing with a scatter plot or not // as this determines what is drawn on the left bool lines = false; double mwidth = 0; double height = pointsize; for(unsigned int i=0;i<styles.size();i++) { if(!markers[i].getColor().isClear()) { mwidth = max(mwidth,markers[i].getRange()*2); height = max(height,mwidth); } if(!styles[i].getColor().isClear()) lines = true; } // Add spacer to the height height += spacer; // width = width needed to draw this // lbegin = x offset where line will begin // lwidth = length of the lines to draw the sample double width = 30; double lbegin = 0; double lwidth = 30; if(mwidth) // If we have markers... { lbegin = mwidth/2; if(lines) { width = mwidth*3; lwidth = mwidth*2; } else { width = mwidth; lwidth = 0; } } // TextStyle TextStyle style; style.setPointSize(pointsize); // Begin drawing? for(unsigned int i=begin;i<begin+n;i++) { // Draw the sample: double y = frame.getHeight() - height/2.0 - height*i; Line l(lbegin+spacer,y,lbegin+lwidth+spacer,y); l.setStrokeStyle(styles[i]); l.setMarker(markers[i]); frame << l; // Add the series title frame << Text(titles[i].c_str(),width+spacer*2,(y-(pointsize/2.0)),style,Text::LEFT); } }
void CTextStyle::FromOldStyle(const TextStyle& style) { // Set some defaults. SetDefault(); // Copy the style information over. Font(style.get_face()); Size(MakeFixed(style.get_size(), style.get_size_fraction())); BaseSize(MakeFixed(style.get_base_size(), style.get_base_size_fraction())); Expansion(DivFixed(MakeFixed(style.get_base_size(), style.get_base_size_fraction()), MakeFixed(FONT_EXPANSION_UNIT))); Fill(style.get_pattern(), style.get_color()); Outline(style.get_outline(), style.get_color()); Shadow(style.get_shadow(), style.get_color()); m_Character.m_nEffectsVersion = 1; XFlipped(style.get_xflipped()); YFlipped(style.get_yflipped()); // Color(style.get_color()); Alignment(style.get_line_alignment()); VerticalAlignment(style.get_vertical_alignment()); // Left and right margin should be zero (default) unless set by user. // This fixes a problem converting old warp text boxes - they should // always have zero margins! LeftMargin(0); RightMargin(0); // LeftMargin(PageToInches(style.get_left_margin())); // RightMargin(PageToInches(style.get_right_margin())); LeadingType(LEADING_lines); Leading(MakeFixed(0.875)); Underline(style.UnderlineStyle()); // Update our metrics. UpdateFontMetrics(); }
Score::FileError Score::read114(XmlReader& e) { if (parentScore()) setMscVersion(parentScore()->mscVersion()); for (unsigned int i = 0; i < sizeof(style114)/sizeof(*style114); ++i) style()->set(style114[i].idx, style114[i].val); // old text style defaults TextStyle ts = style()->textStyle("Chord Symbol"); ts.setYoff(-4.0); style()->setTextStyle(ts); TempoMap tm; while (e.readNextStartElement()) { e.setTrack(-1); const QStringRef& tag(e.name()); if (tag == "Staff") readStaff(e); else if (tag == "KeySig") { // not supported KeySig* ks = new KeySig(this); ks->read(e); // customKeysigs.append(ks); delete ks; } else if (tag == "siglist") _sigmap->read(e, _fileDivision); else if (tag == "programVersion") { _mscoreVersion = e.readElementText(); parseVersion(_mscoreVersion); } else if (tag == "programRevision") _mscoreRevision = e.readInt(); else if (tag == "Mag" || tag == "MagIdx" || tag == "xoff" || tag == "Symbols" || tag == "cursorTrack" || tag == "yoff") e.skipCurrentElement(); // obsolete else if (tag == "tempolist") { // store the tempo list to create invisible tempo text later qreal tempo = e.attribute("fix","2.0").toDouble(); tm.setRelTempo(tempo); while (e.readNextStartElement()) { if (e.name() == "tempo") { int tick = e.attribute("tick").toInt(); double tmp = e.readElementText().toDouble(); tick = (tick * MScore::division + _fileDivision/2) / _fileDivision; auto pos = tm.find(tick); if (pos != tm.end()) tm.erase(pos); tm.setTempo(tick, tmp); } else if (e.name() == "relTempo") e.readElementText(); else e.unknown(); } } else if (tag == "playMode") _playMode = PlayMode(e.readInt()); else if (tag == "SyntiSettings") _synthesizerState.read(e); else if (tag == "Spatium") _style.setSpatium (e.readDouble() * MScore::DPMM); else if (tag == "Division") _fileDivision = e.readInt(); else if (tag == "showInvisible") _showInvisible = e.readInt(); else if (tag == "showFrames") _showFrames = e.readInt(); else if (tag == "showMargins") _showPageborders = e.readInt(); else if (tag == "Style") { qreal sp = _style.spatium(); _style.load(e); // adjust this now so chords render properly on read // other style adjustments can wait until reading is finished if (style(StyleIdx::useGermanNoteNames).toBool()) style()->set(StyleIdx::useStandardNoteNames, false); if (_layoutMode == LayoutMode::FLOAT) { // style should not change spatium in // float mode _style.setSpatium(sp); } } else if (tag == "TextStyle") { TextStyle s; s.read(e); qreal spMM = _style.spatium() / MScore::DPMM; if (s.frameWidthMM() != 0.0) s.setFrameWidth(Spatium(s.frameWidthMM() / spMM)); if (s.paddingWidthMM() != 0.0) s.setPaddingWidth(Spatium(s.paddingWidthMM() / spMM)); \ // convert 1.2 text styles s.setName(convertOldTextStyleNames(s.name())); if (s.name() == "Lyrics Odd Lines" || s.name() == "Lyrics Even Lines") s.setAlign((s.align() & ~ Align(AlignmentFlags::VMASK)) | AlignmentFlags::BASELINE); _style.setTextStyle(s); } else if (tag == "page-layout") { if (_layoutMode != LayoutMode::FLOAT && _layoutMode != LayoutMode::SYSTEM) { PageFormat pf; pf.copy(*pageFormat()); pf.read(e, this); setPageFormat(pf); } else e.skipCurrentElement(); } else if (tag == "copyright" || tag == "rights") { Text* text = new Text(this); text->read(e); text->layout(); setMetaTag("copyright", text->plainText()); delete text; } else if (tag == "movement-number") setMetaTag("movementNumber", e.readElementText()); else if (tag == "movement-title") setMetaTag("movementTitle", e.readElementText()); else if (tag == "work-number") setMetaTag("workNumber", e.readElementText()); else if (tag == "work-title") setMetaTag("workTitle", e.readElementText()); else if (tag == "source") setMetaTag("source", e.readElementText()); else if (tag == "metaTag") { QString name = e.attribute("name"); setMetaTag(name, e.readElementText()); } else if (tag == "Part") { Part* part = new Part(this); part->read114(e); _parts.push_back(part); } else if (tag == "Slur") { Slur* slur = new Slur(this); slur->read(e); addSpanner(slur); } else if ((tag == "HairPin") || (tag == "Ottava") || (tag == "TextLine") || (tag == "Volta") || (tag == "Trill") || (tag == "Pedal")) { Spanner* s = static_cast<Spanner*>(Element::name2Element(tag, this)); s->read(e); if (s->track() == -1) s->setTrack(e.track()); else e.setTrack(s->track()); // update current track if (s->tick() == -1) s->setTick(e.tick()); else e.initTick(s->tick()); // update current tick if (s->track2() == -1) s->setTrack2(s->track()); if (s->ticks() == 0) { delete s; qDebug("zero spanner %s ticks: %d", s->name(), s->ticks()); } else { addSpanner(s); } } else if (tag == "Excerpt") { if (MScore::noExcerpts) e.skipCurrentElement(); else { Excerpt* ex = new Excerpt(this); ex->read(e); _excerpts.append(ex); } } else if (tag == "Beam") { Beam* beam = new Beam(this); beam->read(e); beam->setParent(0); // _beams.append(beam); } else if (tag == "name") setName(e.readElementText()); else e.unknown(); } if (e.error() != XmlStreamReader::NoError) return FileError::FILE_BAD_FORMAT; int n = nstaves(); for (int idx = 0; idx < n; ++idx) { Staff* s = _staves[idx]; int track = idx * VOICES; // check barLineSpan if (s->barLineSpan() > (n - idx)) { qDebug("read114: invalid bar line span %d (max %d)", s->barLineSpan(), n - idx); s->setBarLineSpan(n - idx); } for (auto i : e.clefs(idx)) { int tick = i.first; ClefType clefId = i.second; Measure* m = tick2measure(tick); if (!m) continue; if ((tick == m->tick()) && m->prevMeasure()) m = m->prevMeasure(); Segment* seg = m->getSegment(Segment::Type::Clef, tick); if (seg->element(track)) static_cast<Clef*>(seg->element(track))->setGenerated(false); else { Clef* clef = new Clef(this); clef->setClefType(clefId); clef->setTrack(track); clef->setParent(seg); clef->setGenerated(false); seg->add(clef); } } // create missing KeySig KeyList* km = s->keyList(); for (auto i = km->begin(); i != km->end(); ++i) { int tick = i->first; if (tick < 0) { qDebug("read114: Key tick %d", tick); continue; } if (tick == 0 && i->second.key() == Key::C) continue; Measure* m = tick2measure(tick); if (!m) //empty score break; Segment* seg = m->getSegment(Segment::Type::KeySig, tick); if (seg->element(track)) static_cast<KeySig*>(seg->element(track))->setGenerated(false); else { KeySigEvent ke = i->second; KeySig* ks = new KeySig(this); ks->setKeySigEvent(ke); ks->setParent(seg); ks->setTrack(track); ks->setGenerated(false); seg->add(ks); } } } for (std::pair<int,Spanner*> p : spanner()) { Spanner* s = p.second; if (s->type() != Element::Type::SLUR) { if (s->type() == Element::Type::VOLTA) { Volta* volta = static_cast<Volta*>(s); volta->setAnchor(Spanner::Anchor::MEASURE); } } if (s->type() == Element::Type::OTTAVA || s->type() == Element::Type::PEDAL || s->type() == Element::Type::TRILL || s->type() == Element::Type::TEXTLINE) { qreal yo = 0; if (s->type() == Element::Type::OTTAVA) { // fix ottava position yo = styleS(StyleIdx::ottavaY).val() * spatium(); if (s->placement() == Element::Placement::BELOW) yo = -yo + s->staff()->height(); } else if (s->type() == Element::Type::PEDAL) { yo = styleS(StyleIdx::pedalY).val() * spatium(); } else if (s->type() == Element::Type::TRILL) { yo = styleS(StyleIdx::trillY).val() * spatium(); } else if (s->type() == Element::Type::TEXTLINE) { yo = -5.0 * spatium(); } if (!s->spannerSegments().isEmpty()) { for (SpannerSegment* seg : s->spannerSegments()) { if (!seg->userOff().isNull()) seg->setUserYoffset(seg->userOff().y() - yo); } } else { s->setUserYoffset(-yo); } } } connectTies(); // // remove "middle beam" flags from first ChordRest in // measure // for (Measure* m = firstMeasure(); m; m = m->nextMeasure()) { int tracks = nstaves() * VOICES; bool first = true; for (int track = 0; track < tracks; ++track) { for (Segment* s = m->first(); s; s = s->next()) { if (s->segmentType() != Segment::Type::ChordRest) continue; ChordRest* cr = static_cast<ChordRest*>(s->element(track)); if (cr) { if(cr->type() == Element::Type::REST) { Rest* r = static_cast<Rest*>(cr); if (!r->userOff().isNull()) { int lineOffset = r->computeLineOffset(); qreal lineDist = r->staff() ? r->staff()->staffType()->lineDistance().val() : 1.0; r->rUserYoffset() -= (lineOffset * .5 * lineDist * r->spatium()); } } if(!first) { switch(cr->beamMode()) { case Beam::Mode::AUTO: case Beam::Mode::BEGIN: case Beam::Mode::END: case Beam::Mode::NONE: break; case Beam::Mode::MID: case Beam::Mode::BEGIN32: case Beam::Mode::BEGIN64: cr->setBeamMode(Beam::Mode::BEGIN); break; case Beam::Mode::INVALID: if (cr->type() == Element::Type::CHORD) cr->setBeamMode(Beam::Mode::AUTO); else cr->setBeamMode(Beam::Mode::NONE); break; } first = false; } } } } } for (MeasureBase* mb = _measures.first(); mb; mb = mb->next()) { if (mb->type() == Element::Type::VBOX) { Box* b = static_cast<Box*>(mb); qreal y = point(styleS(StyleIdx::staffUpperBorder)); b->setBottomGap(y); } } _fileDivision = MScore::division; // // sanity check for barLineSpan and update ottavas // foreach(Staff* staff, _staves) { int barLineSpan = staff->barLineSpan(); int idx = staffIdx(staff); int n = nstaves(); if (idx + barLineSpan > n) { qDebug("bad span: idx %d span %d staves %d", idx, barLineSpan, n); staff->setBarLineSpan(n - idx); } staff->updateOttava(); }
Font &get_font(Canvas &canvas) { if (font.is_null()) font = text_style.get_font(canvas); return font; }
void EditStyle::getValues() { lstyle.set(ST_staffUpperBorder, Spatium(staffUpperBorder->value())); lstyle.set(ST_staffLowerBorder, Spatium(staffLowerBorder->value())); lstyle.set(ST_staffDistance, Spatium(staffDistance->value())); lstyle.set(ST_akkoladeDistance, Spatium(akkoladeDistance->value())); lstyle.set(ST_minSystemDistance, Spatium(minSystemDistance->value())); lstyle.set(ST_maxSystemDistance, Spatium(maxSystemDistance->value())); lstyle.set(ST_lyricsDistance, Spatium(lyricsDistance->value())); lstyle.set(ST_lyricsMinBottomDistance, Spatium(lyricsMinBottomDistance->value())); lstyle.set(ST_lyricsLineHeight, Spatium(lyricsLineHeight->value() * .01)); lstyle.set(ST_systemFrameDistance, Spatium(systemFrameDistance->value())); lstyle.set(ST_frameSystemDistance, Spatium(frameSystemDistance->value())); lstyle.set(ST_minMeasureWidth, Spatium(minMeasureWidth_2->value())); lstyle.set(ST_barWidth, Spatium(barWidth->value())); lstyle.set(ST_endBarWidth, Spatium(endBarWidth->value())); lstyle.set(ST_endBarDistance, Spatium(endBarDistance->value())); lstyle.set(ST_doubleBarWidth, Spatium(doubleBarWidth->value())); lstyle.set(ST_doubleBarDistance, Spatium(doubleBarDistance->value())); lstyle.set(ST_repeatBarTips, showRepeatBarTips->isChecked()); lstyle.set(ST_startBarlineSingle, showStartBarlineSingle->isChecked()); lstyle.set(ST_startBarlineMultiple, showStartBarlineMultiple->isChecked()); lstyle.set(ST_measureSpacing, measureSpacing->value()); lstyle.set(ST_minNoteDistance, Spatium(minNoteDistance->value())); lstyle.set(ST_barNoteDistance, Spatium(barNoteDistance->value())); lstyle.set(ST_barAccidentalDistance, Spatium(barAccidentalDistance->value())); lstyle.set(ST_multiMeasureRestMargin, Spatium(multiMeasureRestMargin->value())); lstyle.set(ST_noteBarDistance, Spatium(noteBarDistance->value())); lstyle.set(ST_showMeasureNumber, showMeasureNumber->isChecked()); lstyle.set(ST_showMeasureNumberOne, showFirstMeasureNumber->isChecked()); lstyle.set(ST_measureNumberInterval, intervalMeasureNumber->value()); lstyle.set(ST_measureNumberSystem, showEverySystemMeasureNumber->isChecked()); lstyle.set(ST_measureNumberAllStaffs, showAllStaffsMeasureNumber->isChecked()); lstyle.set(ST_clefLeftMargin, Spatium(clefLeftMargin->value())); lstyle.set(ST_keysigLeftMargin, Spatium(keysigLeftMargin->value())); lstyle.set(ST_timesigLeftMargin, Spatium(timesigLeftMargin->value())); lstyle.set(ST_clefKeyRightMargin, Spatium(clefKeyRightMargin->value())); lstyle.set(ST_clefBarlineDistance, Spatium(clefBarlineDistance->value())); lstyle.set(ST_staffLineWidth, Spatium(staffLineWidth->value())); lstyle.set(ST_beamWidth, Spatium(beamWidth->value())); lstyle.set(ST_beamDistance, beamDistance->value()); lstyle.set(ST_beamMinLen, Spatium(beamMinLen->value())); lstyle.set(ST_beamNoSlope, beamNoSlope->isChecked()); lstyle.set(ST_graceNoteMag, graceNoteSize->value() * 0.01); lstyle.set(ST_smallStaffMag, smallStaffSize->value() * 0.01); lstyle.set(ST_smallNoteMag, smallNoteSize->value() * 0.01); lstyle.set(ST_smallClefMag, smallClefSize->value() * 0.01); lstyle.set(ST_lastSystemFillLimit, lastSystemFillThreshold->value() * 0.01); lstyle.set(ST_hairpinY, Spatium(hairpinY->value())); lstyle.set(ST_hairpinLineWidth, Spatium(hairpinLineWidth->value())); lstyle.set(ST_hairpinHeight, Spatium(hairpinHeight->value())); lstyle.set(ST_hairpinContHeight, Spatium(hairpinContinueHeight->value())); lstyle.set(ST_genClef, genClef->isChecked()); lstyle.set(ST_genKeysig, genKeysig->isChecked()); lstyle.set(ST_genTimesig, genTimesig->isChecked()); lstyle.set(ST_genCourtesyTimesig, genCourtesyTimesig->isChecked()); lstyle.set(ST_genCourtesyKeysig, genCourtesyKeysig->isChecked()); lstyle.set(ST_genCourtesyClef, genCourtesyClef->isChecked()); bool customChords = false; if (chordsStandard->isChecked()) lstyle.set(ST_chordStyle, QString("std")); else if (chordsJazz->isChecked()) lstyle.set(ST_chordStyle, QString("jazz")); else { lstyle.set(ST_chordStyle, QString("custom")); customChords = true; } lstyle.set(ST_chordsXmlFile, chordsXmlFile->isChecked()); if (lstyle.value(ST_chordDescriptionFile).toString() != chordDescriptionFile->text()) { ChordList* cl = new ChordList(); if (lstyle.value(ST_chordsXmlFile).toBool()) cl->read("chords.xml"); cl->read(chordDescriptionFile->text()); lstyle.setChordList(cl, customChords); lstyle.set(ST_chordDescriptionFile, chordDescriptionFile->text()); } lstyle.set(ST_useStandardNoteNames, useStandardNoteNames->isChecked()); lstyle.set(ST_useGermanNoteNames, useGermanNoteNames->isChecked()); lstyle.set(ST_useSolfeggioNoteNames, useSolfeggioNoteNames->isChecked()); lstyle.set(ST_lowerCaseMinorChords, lowerCaseMinorChords->isChecked()); lstyle.set(ST_concertPitch, concertPitch->isChecked()); lstyle.set(ST_createMultiMeasureRests, multiMeasureRests->isChecked()); lstyle.set(ST_minEmptyMeasures, minEmptyMeasures->value()); lstyle.set(ST_minMMRestWidth, Spatium(minMeasureWidth->value())); lstyle.set(ST_hideEmptyStaves, hideEmptyStaves->isChecked()); lstyle.set(ST_dontHideStavesInFirstSystem, dontHideStavesInFirstSystem->isChecked()); lstyle.set(ST_accidentalNoteDistance, Spatium(accidentalNoteDistance->value())); lstyle.set(ST_accidentalDistance, Spatium(accidentalDistance->value())); lstyle.set(ST_dotMag, dotMag->value() * 0.01); lstyle.set(ST_dotNoteDistance, Spatium(noteDotDistance->value())); lstyle.set(ST_dotDotDistance, Spatium(dotDotDistance->value())); lstyle.set(ST_stemWidth, Spatium(stemWidth->value())); lstyle.set(ST_ledgerLineWidth, Spatium(ledgerLineWidth->value())); lstyle.set(ST_ledgerLineLength, Spatium(ledgerLineLength->value())); lstyle.set(ST_bracketWidth, Spatium(bracketWidth->value())); lstyle.set(ST_bracketDistance, Spatium(bracketDistance->value())); lstyle.set(ST_akkoladeWidth, Spatium(akkoladeWidth->value())); lstyle.set(ST_akkoladeBarDistance, Spatium(akkoladeBarDistance->value())); lstyle.set(ST_propertyDistanceHead, Spatium(propertyDistanceHead->value())); lstyle.set(ST_propertyDistanceStem, Spatium(propertyDistanceStem->value())); lstyle.set(ST_propertyDistance, Spatium(propertyDistance->value())); lstyle.set(ST_articulationMag, articulationMag->value() * 0.01); lstyle.set(ST_shortenStem, shortenStem->isChecked()); lstyle.set(ST_shortStemProgression, Spatium(shortStemProgression->value())); lstyle.set(ST_shortestStem, Spatium(shortestStem->value())); lstyle.set(ST_ArpeggioNoteDistance, Spatium(arpeggioNoteDistance->value())); lstyle.set(ST_ArpeggioLineWidth, Spatium(arpeggioLineWidth->value())); lstyle.set(ST_ArpeggioHookLen, Spatium(arpeggioHookLen->value())); lstyle.set(ST_FixMeasureNumbers, fixNumberMeasures->value()); lstyle.set(ST_FixMeasureWidth, fixMeasureWidth->isChecked()); lstyle.set(ST_SlurEndWidth, Spatium(slurEndLineWidth->value())); lstyle.set(ST_SlurMidWidth, Spatium(slurMidLineWidth->value())); lstyle.set(ST_SlurDottedWidth, Spatium(slurDottedLineWidth->value())); lstyle.set(ST_MusicalSymbolFont, musicalSymbolFont->currentText()); lstyle.set(ST_showHeader, showHeader->isChecked()); lstyle.set(ST_headerStyled, headerStyled->isChecked()); lstyle.set(ST_headerFirstPage, showHeaderFirstPage->isChecked()); lstyle.set(ST_headerOddEven, headerOddEven->isChecked()); if (headerStyled->isChecked()) { lstyle.set(ST_evenHeaderL, evenHeaderL->toPlainText()); lstyle.set(ST_evenHeaderC, evenHeaderC->toPlainText()); lstyle.set(ST_evenHeaderR, evenHeaderR->toPlainText()); lstyle.set(ST_oddHeaderL, oddHeaderL->toPlainText()); lstyle.set(ST_oddHeaderC, oddHeaderC->toPlainText()); lstyle.set(ST_oddHeaderR, oddHeaderR->toPlainText()); } else { lstyle.set(ST_evenHeaderL, evenHeaderL->toHtml()); lstyle.set(ST_evenHeaderC, evenHeaderC->toHtml()); lstyle.set(ST_evenHeaderR, evenHeaderR->toHtml()); lstyle.set(ST_oddHeaderL, oddHeaderL->toHtml()); lstyle.set(ST_oddHeaderC, oddHeaderC->toHtml()); lstyle.set(ST_oddHeaderR, oddHeaderR->toHtml()); } lstyle.set(ST_showFooter, showFooter->isChecked()); lstyle.set(ST_footerStyled, footerStyled->isChecked()); lstyle.set(ST_footerFirstPage, showFooterFirstPage->isChecked()); lstyle.set(ST_footerOddEven, footerOddEven->isChecked()); if (footerStyled->isChecked()) { lstyle.set(ST_evenFooterL, evenFooterL->toPlainText()); lstyle.set(ST_evenFooterC, evenFooterC->toPlainText()); lstyle.set(ST_evenFooterR, evenFooterR->toPlainText()); lstyle.set(ST_oddFooterL, oddFooterL->toPlainText()); lstyle.set(ST_oddFooterC, oddFooterC->toPlainText()); lstyle.set(ST_oddFooterR, oddFooterR->toPlainText()); } else { lstyle.set(ST_evenFooterL, evenFooterL->toHtml()); lstyle.set(ST_evenFooterC, evenFooterC->toHtml()); lstyle.set(ST_evenFooterR, evenFooterR->toHtml()); lstyle.set(ST_oddFooterL, oddFooterL->toHtml()); lstyle.set(ST_oddFooterC, oddFooterC->toHtml()); lstyle.set(ST_oddFooterR, oddFooterR->toHtml()); } // figured bass int idx = comboFBFont->currentIndex(); QString family; if(FiguredBass::fontData(idx, &family, 0, 0, 0)) lstyle.set(ST_figuredBassFontFamily, family); qreal size = doubleSpinFBSize->value(); qreal vPos = doubleSpinFBVertPos->value(); lstyle.set(ST_figuredBassFontSize, size); lstyle.set(ST_figuredBassYOffset, vPos); lstyle.set(ST_figuredBassLineHeight, ((double)spinFBLineHeight->value()) / 100.0); lstyle.set(ST_figuredBassAlignment, radioFBTop->isChecked() ? 0 : 1); lstyle.set(ST_figuredBassStyle, radioFBModern->isChecked() ? 0 : 1); // copy to text style data relevant to it (LineHeight and Style are not in text style); // offsetType is necessarily OFFSET_SPATIUM const TextStyle fbOld = lstyle.textStyle(TEXT_STYLE_FIGURED_BASS); if (family != fbOld.family() || size != fbOld.size() || vPos != fbOld.offset().y() || fbOld.offsetType() != OFFSET_SPATIUM) { TextStyle fbNew(fbOld); fbNew.setFamily(family); fbNew.setSize(size); fbNew.setYoff(vPos); fbNew.setOffsetType(OFFSET_SPATIUM); lstyle.setTextStyle(fbNew); } for (int i = 0; i < ARTICULATIONS; ++i) { QComboBox* cb = static_cast<QComboBox*>(articulationTable->cellWidget(i, 1)); lstyle.setArticulationAnchor(i, ArticulationAnchor(cb->itemData(cb->currentIndex()).toInt())); } lstyle.set(ST_voltaY, Spatium(voltaY->value())); lstyle.set(ST_voltaHook, Spatium(voltaHook->value())); lstyle.set(ST_voltaLineWidth, Spatium(voltaLineWidth->value())); lstyle.set(ST_voltaLineStyle, voltaLineStyle->currentIndex() + 1); lstyle.set(ST_ottavaY, Spatium(ottavaY->value())); lstyle.set(ST_ottavaHook, Spatium(ottavaHook->value())); lstyle.set(ST_ottavaLineWidth, Spatium(ottavaLineWidth->value())); lstyle.set(ST_ottavaLineStyle, ottavaLineStyle->currentIndex() + 1); lstyle.set(ST_ottavaNumbersOnly, ottavaNumbersOnly->isChecked()); lstyle.set(ST_pedalY, Spatium(pedalY->value())); lstyle.set(ST_pedalLineWidth, Spatium(pedalLineWidth->value())); lstyle.set(ST_pedalLineStyle, pedalLineStyle->currentIndex() + 1); lstyle.set(ST_trillY, Spatium(trillY->value())); lstyle.set(ST_harmonyY, Spatium(harmonyY->value())); lstyle.set(ST_harmonyFretDist, Spatium(harmonyFretDist->value())); lstyle.set(ST_minHarmonyDistance, Spatium(minHarmonyDistance->value())); lstyle.set(ST_tabClef, clefTab1->isChecked() ? CLEF_TAB : CLEF_TAB2); lstyle.set(ST_crossMeasureValues, crossMeasureValues->isChecked()); lstyle.set(ST_keySigNaturals, radioKeySigNatNone->isChecked() ? NAT_NONE : (radioKeySigNatBefore->isChecked() ? NAT_BEFORE : NAT_AFTER) ); }
void dbgPrint( const TextStyle& style ) { std::cout << " font name : " << style.GetFontName() << std::endl; std::cout << " font style : " << style.GetFontStyle() << std::endl; std::cout << " font point size : " << style.GetFontPointSize() << std::endl; std::cout << " weight : " << style.GetWeight() << std::endl; std::cout << " text color : " << style.GetTextColor() << std::endl; std::cout << " italics : " << style.GetItalics() << std::endl; std::cout << " underline : " << style.GetUnderline() << std::endl; std::cout << " shadow : " << style.GetShadow() << std::endl; std::cout << " shadow color : " << style.GetShadowColor() << std::endl; std::cout << " shadow offset : " << style.GetShadowOffset() << std::endl; std::cout << " glow : " << style.GetGlow() << std::endl; std::cout << " italics angle : " << style.GetItalicsAngle() << std::endl; std::cout << " glow color : " << style.GetGlowColor() << std::endl; std::cout << " glow intensity : " << style.GetGlowIntensity() << std::endl; std::cout << " smooth edge : " << style.GetSmoothEdge() << std::endl; std::cout << " outline : " << style.GetOutline() << std::endl; std::cout << " outline color : " << style.GetOutlineColor() << std::endl; std::cout << " outline thickness : " << style.GetOutlineThickness() << std::endl; }