本文整理汇总了C++中BTextView::GetFontAndColor方法的典型用法代码示例。如果您正苦于以下问题:C++ BTextView::GetFontAndColor方法的具体用法?C++ BTextView::GetFontAndColor怎么用?C++ BTextView::GetFontAndColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTextView
的用法示例。
在下文中一共展示了BTextView::GetFontAndColor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ShowAboutWindow
void ShowAboutWindow(void)
{
char str[512];
sprintf(str,
"Basilisk II\nVersion %d.%d\n\n"
"Copyright " B_UTF8_COPYRIGHT " 1997-2008 Christian Bauer et al.\n"
"E-mail: [email protected]\n"
"http://www.uni-mainz.de/~bauec002/B2Main.html\n\n"
"Basilisk II comes with ABSOLUTELY NO\n"
"WARRANTY. This is free software, and\n"
"you are welcome to redistribute it\n"
"under the terms of the GNU General\n"
"Public License.\n",
VERSION_MAJOR, VERSION_MINOR
);
BAlert *about = new BAlert("", str, GetString(STR_OK_BUTTON), NULL, NULL, B_WIDTH_FROM_LABEL);
BTextView *theText = about->TextView();
if (theText) {
theText->SetStylable(true);
theText->Select(0, 11);
BFont ourFont;
theText->SetFontAndColor(be_bold_font);
theText->GetFontAndColor(2, &ourFont, NULL);
ourFont.SetSize(24);
theText->SetFontAndColor(&ourFont);
}
about->Go();
}
示例2: AboutText
void
HWindow::AboutRequested()
{
const char* aboutText = AboutText();
if (aboutText == NULL)
return;
BAlert *about = new BAlert("About", aboutText, "Cool");
BTextView *v = about->TextView();
if (v) {
rgb_color red = {255, 0, 51, 255};
rgb_color blue = {0, 102, 255, 255};
v->SetStylable(true);
char *text = (char*)v->Text();
char *s = text;
// set all Be in blue and red
while ((s = strstr(s, "Be")) != NULL) {
int32 i = s - text;
v->SetFontAndColor(i, i+1, NULL, 0, &blue);
v->SetFontAndColor(i+1, i+2, NULL, 0, &red);
s += 2;
}
// first text line
s = strchr(text, '\n');
BFont font;
v->GetFontAndColor(0, &font);
font.SetSize(12); // font.SetFace(B_OUTLINED_FACE);
v->SetFontAndColor(0, s-text+1, &font, B_FONT_SIZE);
};
about->SetFlags(about->Flags() | B_CLOSE_ON_ESCAPE);
about->Go();
}
示例3: AboutRequested
void BepdfApplication::AboutRequested()
{
BString version;
BString str("BePDF\n");
str += B_TRANSLATE("Version");
str += " ";
str += GetVersion(version);
str += "\n";
str += bePDFCopyright;
str += "\n";
str += B_TRANSLATE_COMMENT("Language 'English', translated by the BePDF authors.",
"Replace 'English' with the language you're translating to, and 'the BePDF authors' with your name or your translation group's name.");
str += "\n\n";
str += BString().SetToFormat(B_TRANSLATE_COMMENT("BePDF is based on XPDF %s, %s.", "XPDF version, copyright"),
xpdfVersion, xpdfCopyright);
str += GPLCopyright;
BAlert *about = new BAlert("About", str.String(), "OK");
BTextView *v = about->TextView();
if (v) {
rgb_color red = {255, 0, 51, 255};
rgb_color blue = {0, 102, 255, 255};
v->SetStylable(true);
char *text = (char*)v->Text();
char *s = text;
// set all Be in BePDF in blue and red
while ((s = strstr(s, "BePDF")) != NULL) {
int32 i = s - text;
v->SetFontAndColor(i, i+1, NULL, 0, &blue);
v->SetFontAndColor(i+1, i+2, NULL, 0, &red);
s += 2;
}
// first text line
s = strchr(text, '\n');
BFont font;
v->GetFontAndColor(0, &font);
font.SetSize(16);
v->SetFontAndColor(0, s-text+1, &font, B_FONT_SIZE);
};
about->Go();
}