本文整理汇总了C++中TextStyle类的典型用法代码示例。如果您正苦于以下问题:C++ TextStyle类的具体用法?C++ TextStyle怎么用?C++ TextStyle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextStyle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: UtcDaliTextInputGetMarkupText
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;
}
开发者ID:Tarnyko,项目名称:dal-toolkit,代码行数:31,代码来源:utc-Dali-TextInput.cpp
示例2: tr
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);
}
开发者ID:SSMN,项目名称:MuseScore,代码行数:31,代码来源:textstyle.cpp
示例3: preRender
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);
}
开发者ID:astrellon,项目名称:GPP,代码行数:60,代码来源:gfx_text_field2.cpp
示例4: saveStyle
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
}
开发者ID:Igevorse,项目名称:MuseScore,代码行数:8,代码来源:textstyle.cpp
示例5: getStyle
/* 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();
}
开发者ID:Monsterovich,项目名称:SLADE,代码行数:12,代码来源:TextStyle.cpp
示例6: saveStyle
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;
}
开发者ID:SSMN,项目名称:MuseScore,代码行数:10,代码来源:textstyle.cpp
示例7: convertTextStyleToJSON
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() << "\""
<< "}";
};
开发者ID:mheinsen,项目名称:seec,代码行数:13,代码来源:StateGraphViewer.cpp
示例8: main
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;
}
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:51,代码来源:test_textstyle_main.cpp
示例9: set_ip
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;
}
}
}
开发者ID:calref,项目名称:cboe,代码行数:49,代码来源:field.cpp
示例10: drawComplexText
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);
}
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:28,代码来源:FontWin.cpp
示例11: floatWidthForSimpleText
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);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:31,代码来源:BTFont.cpp
示例12: drawComplexText
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);
}
开发者ID:UIKit0,项目名称:WebkitAIR,代码行数:26,代码来源:FontGdkApollo.cpp
示例13: size_font
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;
}
开发者ID:milasudril,项目名称:glinde,代码行数:18,代码来源:paragraph.cpp
示例14: tr
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();
}
开发者ID:Igevorse,项目名称:MuseScore,代码行数:42,代码来源:textstyle.cpp
示例15: selectionRectForComplexText
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;
}
开发者ID:UIKit0,项目名称:WebkitAIR,代码行数:23,代码来源:FontGdkApollo.cpp
示例16: replaceTextMacros
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);
}
开发者ID:derAbgang,项目名称:MuseScore,代码行数:36,代码来源:page.cpp
示例17: offsetForPositionForComplexText
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;
}
开发者ID:UIKit0,项目名称:WebkitAIR,代码行数:16,代码来源:FontGdkApollo.cpp
示例18: selectionRectForComplexText
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);
}
开发者ID:cdaffara,项目名称:symbiandump-mw4,代码行数:18,代码来源:FontWin.cpp
示例19: size_box
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;
}
开发者ID:milasudril,项目名称:glinde,代码行数:19,代码来源:paragraph.cpp
示例20: floatWidthForComplexText
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;
}
开发者ID:UIKit0,项目名称:WebkitAIR,代码行数:19,代码来源:FontGdkApollo.cpp
注:本文中的TextStyle类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论