本文整理汇总了C++中ParagraphStyle::SetAlignment方法的典型用法代码示例。如果您正苦于以下问题:C++ ParagraphStyle::SetAlignment方法的具体用法?C++ ParagraphStyle::SetAlignment怎么用?C++ ParagraphStyle::SetAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParagraphStyle
的用法示例。
在下文中一共展示了ParagraphStyle::SetAlignment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: frame
void
TextDocumentTest::ReadyToRun()
{
Init();
BRect frame(50.0, 50.0, 749.0, 549.0);
BWindow* window = new BWindow(frame, "Text document test",
B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS);
TextDocumentView* documentView = new TextDocumentView("text document view");
BScrollView* scrollView = new BScrollView("text scroll view", documentView,
false, true, B_NO_BORDER);
BuildFontMenu();
BToolBar* toolBar= new BToolBar();
toolBar->AddAction(MENU_FILE_NEW,this,LoadIcon("document_new"));
toolBar->AddAction(MENU_FILE_OPEN,this,LoadIcon("document_open"));
toolBar->AddAction(MENU_FILE_SAVE,this,LoadIcon("document_save"));
toolBar->AddSeparator();
toolBar->AddView(new BButton("StyleList"));
toolBar->AddView(fFontMenuField);
toolBar->AddView(new BButton("Size"));
toolBar->AddSeparator();
toolBar->AddAction(FONTBOLD_MSG,this,LoadIcon("text_bold"),"Bold",NULL,false);
toolBar->AddAction(FONTITALIC_MSG,this,LoadIcon("text_italic"),"Bold",NULL,true);;
toolBar->AddAction(FONTUNDERLINE_MSG,this,LoadIcon("text_underline"),"Bold",NULL,true);;
toolBar->AddSeparator();
/*toolBar->AddView(new BButton("Left"));
toolBar->AddView(new BButton("Center"));
toolBar->AddView(new BButton("Right"));
toolBar->AddView(new BButton("Block"));
toolBar->AddSeparator();
toolBar->AddView(new BButton("Inset Right"));
toolBar->AddView(new BButton("Inset Left"));
toolBar->AddSeparator();
toolBar->AddView(new BButton("Bullet List"));
toolBar->AddSeparator();*/
toolBar->AddGlue();
BToolBar* statusBar= new BToolBar();
BFont* tmpFont = new BFont();
BStringView* stringView = new BStringView("firstStatus","Here will be the Status View");
stringView->GetFont(tmpFont);
tmpFont->SetSize(tmpFont->Size()-2);
stringView->SetFont(tmpFont);
statusBar->AddView(stringView);
statusBar->AddSeparator();
BLayoutBuilder::Group<>(window, B_VERTICAL,0)
.Add(toolBar)
.Add(scrollView)
.SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED))
.Add(statusBar)
;
CharacterStyle regularStyle;
float fontSize = regularStyle.Font().Size();
ParagraphStyle paragraphStyle;
paragraphStyle.SetJustify(true);
paragraphStyle.SetSpacingTop(ceilf(fontSize * 0.6f));
paragraphStyle.SetLineSpacing(ceilf(fontSize * 0.2f));
CharacterStyle boldStyle(regularStyle);
boldStyle.SetBold(true);
CharacterStyle italicStyle(regularStyle);
italicStyle.SetItalic(true);
CharacterStyle italicAndBoldStyle(boldStyle);
italicAndBoldStyle.SetItalic(true);
CharacterStyle bigStyle(regularStyle);
bigStyle.SetFontSize(24);
bigStyle.SetBold(true);
bigStyle.SetForegroundColor(255, 50, 50);
TextDocumentRef document(new TextDocument(), true);
Paragraph paragraph(paragraphStyle);
paragraph.Append(TextSpan("This is a", regularStyle));
paragraph.Append(TextSpan(" test ", bigStyle));
paragraph.Append(TextSpan("to see if ", regularStyle));
paragraph.Append(TextSpan("different", boldStyle));
paragraph.Append(TextSpan(" character styles already work.", regularStyle));
document->Append(paragraph);
paragraphStyle.SetSpacingTop(8.0f);
paragraphStyle.SetAlignment(ALIGN_CENTER);
paragraphStyle.SetJustify(false);
paragraph = Paragraph(paragraphStyle);
paragraph.Append(TextSpan("Different alignment styles ", regularStyle));
paragraph.Append(TextSpan("are", boldStyle));
paragraph.Append(TextSpan(" supported as of now!", regularStyle));
//.........这里部分代码省略.........