本文整理汇总了C++中BTextView::SetText方法的典型用法代码示例。如果您正苦于以下问题:C++ BTextView::SetText方法的具体用法?C++ BTextView::SetText怎么用?C++ BTextView::SetText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTextView
的用法示例。
在下文中一共展示了BTextView::SetText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BTextView
void
DataTranslationsWindow::_ShowInfoView()
{
if (fConfigView) {
fRightBox->RemoveChild(fConfigView);
delete fConfigView;
fConfigView = NULL;
}
BTextView* view = new BTextView("info text");
view->MakeEditable(false);
view->MakeSelectable(false);
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
view->SetText(B_TRANSLATE(
"Use this control panel to set default values for translators, "
"to be used when no other settings are specified by an application."));
BGroupView* group = new BGroupView(B_VERTICAL);
group->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
group->AddChild(view);
float spacing = be_control_look->DefaultItemSpacing();
group->GroupLayout()->SetInsets(spacing, spacing, spacing, spacing);
fRightBox->AddChild(group);
fConfigView = group;
}
示例2: PointForTip
void
DTipWatcherView::ShowTip(BPoint pt, const char *text)
{
if (!text)
return;
Window()->SetWorkspaces(B_CURRENT_WORKSPACE);
fTipView->SetText(text);
// Figure the size of the tip. We do have a maximum width of 200 and a maximum height of 400, but
// we only want to use the maximum size if it's necessary.
fTipView->ResizeTo(200,400);
fTipView->SetTextRect(BRect(2,2,198,398));
int32 lineCount = fTipView->CountLines();
float width = 200.0;
if (lineCount == 1)
width = fTipView->LineWidth() + 4;
float height = fTipView->TextHeight(0,lineCount);
height = (height < 400) ? height : 400;
Window()->ResizeTo(width,height);
fTipView->SetTextRect(BRect(2,2, width - 4, height - 4));
BPoint winpt = PointForTip(pt);
Window()->MoveTo(winpt.x,winpt.y);
Window()->Show();
}
示例3: BMessage
ServiceView::ServiceView(const char* name, const char* executable,
const char* title, const char* description, BNetworkSettings& settings)
:
BView("service", 0),
fName(name),
fExecutable(executable),
fSettings(settings)
{
BStringView* titleView = new BStringView("service", title);
titleView->SetFont(be_bold_font);
titleView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
BTextView* descriptionView = new BTextView("description");
descriptionView->SetText(description);
descriptionView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
descriptionView->MakeEditable(false);
fEnableButton = new BButton("toggler", B_TRANSLATE("Enable"),
new BMessage(kMsgToggleService));
BLayoutBuilder::Group<>(this, B_VERTICAL)
.Add(titleView)
.Add(descriptionView)
.AddGroup(B_HORIZONTAL)
.AddGlue()
.Add(fEnableButton);
SetExplicitMinSize(BSize(200, B_SIZE_UNSET));
_UpdateEnableButton();
fWasEnabled = IsEnabled();
}
示例4: MessageReceived
void
AddWindow::MessageReceived(BMessage *mess){
if(mess->what == 'can'){
BMessenger(this).SendMessage(B_QUIT_REQUESTED);
}
else
if(mess->what == 'sav'){
BTextView *textView = (BTextView*)FindView("rss_url");
if (textView){
BMessage msg(DOWNLOAD_CHANNEL);
msg.AddString("url",textView->Text());
BMessenger(main_window).SendMessage(&msg);
BMessenger(this).SendMessage(B_QUIT_REQUESTED);
}
}
else
if(mess->what== 'past'){
BString url;
mess->FindString("url",&url);
BTextView *textView = (BTextView*)FindView("rss_url");
if (textView){
textView->SetText(url.String());
}
}
else BWindow::MessageReceived(mess);
}
示例5:
int32_t
PTextViewSetText(void *pobject, void *in, void *out, void *extraData)
{
if (!pobject || !in || !out)
return B_ERROR;
PView *parent = static_cast<PView*>(pobject);
if (!parent)
return B_BAD_TYPE;
BTextView *backend = (BTextView*)parent->GetView();
PArgs *inArgs = static_cast<PArgs*>(in);
BString text;
if (inArgs->FindString("text", &text) != B_OK)
return B_ERROR;
int32 length;
if (inArgs->FindInt32("length", &length) != B_OK)
return B_ERROR;
if (backend->Window())
backend->Window()->Lock();
backend->SetText(text.String(), length);
if (backend->Window())
backend->Window()->Unlock();
return B_OK;
}
示例6: BStringView
void
Shelf::StartConfig(BView *view)
{
PRINT(("%p:%s()\n", this, __FUNCTION__));
fInConfig = true;
BStringView* titleString = new BStringView("Title",
B_TRANSLATE("Shelf"));
titleString->SetFont(be_bold_font);
BStringView* copyrightString = new BStringView("Copyright",
B_TRANSLATE("© 2012 François Revol."));
BTextView* helpText = new BTextView("Help Text");
helpText->MakeEditable(false);
helpText->SetViewColor(view->ViewColor());
rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
helpText->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor);
BString help;
help << B_TRANSLATE("Drop replicants on the full-screen window "
"behind the preferences panel.");
//help << "\n\n";
//help << B_TRANSLATE("You can also drop colors.");
helpText->SetText(help.String());
BLayoutBuilder::Group<>(view, B_VERTICAL, B_USE_HALF_ITEM_SPACING)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(titleString)
.Add(copyrightString)
.AddStrut(roundf(be_control_look->DefaultItemSpacing() / 2))
.Add(helpText)
.AddGlue()
.End();
BScreen screen;
fConfigWindow = new BWindow(screen.Frame(), "Shelf Config",
B_UNTYPED_WINDOW, B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE
| B_NOT_MINIMIZABLE | B_NOT_RESIZABLE | B_AVOID_FRONT | B_AVOID_FOCUS);
BView *shelfView = new BView(fConfigWindow->Bounds(), "ShelfView",
B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS);
shelfView->SetViewColor(216, 216, 216, 0);
fConfigWindow->AddChild(shelfView);
fShelfData.Seek(SEEK_SET, 0LL);
fShelf = new BShelf(&fShelfData, shelfView);
fShelf->SetDisplaysZombies(true);
fShelfData.Seek(SEEK_SET, 0LL);
// start the Looper
fConfigWindow->Show();
fConfigWindow->Lock();
fConfigWindow->SendBehind(view->Window());
fConfigWindow->Unlock();
//"\nDrop replicants on me!"
}
示例7: BWindow
window() : BWindow(BRect(30, 30, 300, 300), "BTextView test", B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS)
{
BTextView *textview = new BTextView(Bounds(), "textview", Bounds(),
B_FOLLOW_ALL, B_WILL_DRAW);
AddChild(textview);
textview->SetText("Type into the Antares BTextView!");
textview->MakeFocus();
}
示例8: BTextView
/***********************************************************
* HardWrap
***********************************************************/
void
HWrapTextView::GetHardWrapedText(BString &out)
{
MakeEditable(false);
BTextView *offview = new BTextView(Bounds(),NULL,TextRect(),B_FOLLOW_ALL);
offview->SetText(Text());
BFont font;
uint32 propa;
GetFontAndColor(&font,&propa);
out = "";
offview->SetFontAndColor(&font,B_FONT_ALL);
BString line;
int32 length = offview->TextLength();
float view_width = offview->TextRect().Width();
char c=0;
bool inserted;
for(int32 i=0;i < length;i++)
{
c = offview->ByteAt(i);
if(c == '\n')
{
line = "";
continue;
}
line += c;
if(font.StringWidth(line.String())>=view_width)
{
// Back 1 charactor.
i--;
line.Truncate(line.Length()-1);
// Insert line break.
inserted = false;
int32 len = line.Length();
for(int32 k = 0;k<len;k++)
{
if(offview->CanEndLine(i-k))
{
offview->Insert(i-k,"\n",1);
inserted=true;
i = i-k;
break;
}
}
// If could not find proper position, add line break to end.
if(!inserted)
offview->Insert(i,"\n",1);
line = "";
}
}
out = offview->Text();
delete offview;
MakeEditable(true);
}
示例9: BBitmap
void
ConfigWindow::MakeHowToView()
{
BResources *resources = BApplication::AppResources();
if (resources)
{
size_t length;
char *buffer = (char *)resources->FindResource('ICON',101,&length);
if (buffer)
{
BBitmap *bitmap = new BBitmap(BRect(0,0,63,63),B_CMAP8);
if (bitmap && bitmap->InitCheck() == B_OK)
{
// copy and enlarge a 32x32 8-bit bitmap
char *bits = (char *)bitmap->Bits();
for (int32 i = 0,j = -64;i < length;i++)
{
if ((i % 32) == 0)
j += 64;
char *b = bits + (i << 1) + j;
b[0] = b[1] = b[64] = b[65] = buffer[i];
}
fConfigView->AddChild(new BitmapView(bitmap));
}
else
delete bitmap;
}
}
BRect rect = fConfigView->Bounds();
BTextView *text = new BTextView(rect,NULL,rect,B_FOLLOW_NONE,B_WILL_DRAW);
text->SetViewColor(fConfigView->Parent()->ViewColor());
text->SetAlignment(B_ALIGN_CENTER);
text->SetText(
MDR_DIALECT_CHOICE ("\n\nCreate a new account using the \"Add\" button.\n\n"
"Delete accounts (or only the inbound/outbound) by using the \"Remove\" button on the selected item.\n\n"
"Select an item in the list to edit its configuration.",
"\n\nアカウントの新規作成は\"追加\"ボタンを\n使います。"
"\n\nアカウント自体またはアカウントの\n送受信設定を削除するには\n項目を選択して\"削除\"ボタンを使います。"
"\n\nアカウント内容の変更は、\nマウスで項目をクリックしてください。"));
rect = text->Bounds();
text->ResizeTo(rect.Width(),text->TextHeight(0,42));
text->SetTextRect(rect);
text->MakeEditable(false);
text->MakeSelectable(false);
fConfigView->AddChild(text);
static_cast<CenterContainer *>(fConfigView)->Layout();
}
示例10: BTextView
BTextView*
WizardPageView::CreateDescription(BRect frame, const char* name,
const char* description)
{
BTextView* view = new BTextView(frame, "text",
frame.OffsetToCopy(0, 0),
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
B_WILL_DRAW | B_PULSE_NEEDED | B_FRAME_EVENTS);
view->MakeEditable(false);
view->SetViewColor(ViewColor());
view->SetStylable(true);
view->SetText(description);
return view;
}
示例11: message
void
AboutView::Pulse()
{
char string[255];
system_info info;
get_system_info(&info);
fUptimeView->SetText(UptimeToString(string, sizeof(string)));
fMemView->SetText(MemUsageToString(string, sizeof(string), &info));
if (fScrollRunner == NULL
&& system_time() > fLastActionTime + 10000000) {
BMessage message(SCROLL_CREDITS_VIEW);
//fScrollRunner = new BMessageRunner(this, &message, 25000, -1);
}
}
示例12: locker
void
StringEditor::_UpdateText()
{
BAutolock locker(fEditor);
size_t viewSize = fEditor.ViewSize();
// that may need some more memory...
if ((off_t)viewSize < fEditor.FileSize())
fEditor.SetViewSize(fEditor.FileSize());
const char *buffer;
if (fEditor.GetViewBuffer((const uint8 **)&buffer) == B_OK) {
fTextView->SetText(buffer);
fPreviousText.SetTo(buffer);
}
// restore old view size
fEditor.SetViewSize(viewSize);
}
示例13: appFile
void
ConfigWindow::_MakeHowToView()
{
app_info info;
if (be_app->GetAppInfo(&info) == B_OK) {
BFile appFile(&info.ref, B_READ_ONLY);
BAppFileInfo appFileInfo(&appFile);
if (appFileInfo.InitCheck() == B_OK) {
BBitmap *bitmap = new (nothrow) BBitmap(BRect(0, 0, 63, 63),
B_RGBA32);
if (appFileInfo.GetIcon(bitmap, B_LARGE_ICON) == B_OK) {
fConfigView->AddChild(new BitmapView(bitmap));
} else
delete bitmap;
}
}
BRect rect = fConfigView->Bounds();
BTextView *text = new BTextView(rect, NULL, rect, B_FOLLOW_NONE,
B_WILL_DRAW);
text->SetViewColor(fConfigView->Parent()->ViewColor());
text->SetAlignment(B_ALIGN_CENTER);
text->SetText(B_TRANSLATE(
"\n\nCreate a new account with the Add button.\n\n"
"Remove an account with the Remove button on the selected item.\n\n"
"Select an item in the list to change its settings."));
rect = text->Bounds();
text->ResizeTo(rect.Width(), text->TextHeight(0, 42));
text->SetTextRect(rect);
text->MakeEditable(false);
text->MakeSelectable(false);
fConfigView->AddChild(text);
fConfigView->Layout();
}
示例14: gradiants
void
TestPageView::AttachedToWindow()
{
BTextView* statusView = new BTextView("statusView",
be_plain_font, NULL, B_WILL_DRAW);
statusView->SetInsets(10, 10, 10, 10);
statusView->MakeEditable(false);
statusView->MakeSelectable(false);
const char* title = B_TRANSLATE("Test Page");
BString text;
text << title << "\n\n";
text << B_TRANSLATE(
"Printer: %printer_name%\n"
"Driver: %driver%\n");
text.ReplaceFirst("%printer_name%", fPrinter->Name());
text.ReplaceFirst("%driver%", fPrinter->Driver());
if (strlen(fPrinter->Transport()) > 0) {
text << B_TRANSLATE("Transport: %transport% %transport_address%");
text.ReplaceFirst("%transport%", fPrinter->Transport());
text.ReplaceFirst("%transport_address%", fPrinter->TransportAddress());
}
statusView->SetText(text.String());
BFont font;
statusView->SetStylable(true);
statusView->GetFont(&font);
font.SetFace(B_BOLD_FACE);
font.SetSize(font.Size() * 1.7);
statusView->SetFontAndColor(0, strlen(title), &font);
BGridLayoutBuilder gradiants(2.0);
gradiants.View()->SetViewColor(B_TRANSPARENT_COLOR);
for (int i = 0; i < kNumColorGradients; ++i) {
BStringView* label = new BStringView(kColorGradients[i].name,
kColorGradients[i].name);
// label->SetAlignment(B_ALIGN_RIGHT);
gradiants.Add(label, 0, i);
gradiants.Add(new ColorGradientView(kColorGradients[i].color), 1, i);
}
SetLayout(new BGroupLayout(B_HORIZONTAL));
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
.Add(statusView)
.Add(new LeafView())
)
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
.Add(gradiants, 0.60)
.Add(new RadialLinesView(), 0.40)
)
.AddGlue()
.End()
);
// set layout background color to transparent instead
// of default UI panel color
ChildAt(0)->SetViewColor(B_TRANSPARENT_COLOR);
}
示例15: BMessage
//.........这里部分代码省略.........
"partitions to make room.\n\n\n");
infoText << B_TRANSLATE(
"2) The Installer will make the Haiku partition itself bootable, "
"but takes no steps to integrate Haiku into an existing boot menu. "
"If you have GRUB already installed, you can add Haiku to its boot "
"menu. Depending on what version of GRUB you use, this is done "
"differently.\n\n\n");
infoText << B_TRANSLATE(
"2.1) GRUB (since os-prober v1.44)\n");
infoText << B_TRANSLATE(
"Starting with os-prober v1.44 (e.g. in Ubuntu 11.04 or later), Haiku "
"should be recognized out of the box. To add Haiku to the GRUB menu, "
"open a Terminal and enter:\n\n");
infoText << B_TRANSLATE(
"\tsudo update-grub\n\n\n");
infoText << B_TRANSLATE(
"2.2) GRUB 2\n");
infoText << B_TRANSLATE(
"If the os-prober approach doesn't work for you, GRUB 2 uses an extra "
"configuration file to add custom entries to the boot menu. To add "
"them to the top, you have to create/edit a file by launching your "
"favorite editor from a Terminal like this:\n\n");
infoText << B_TRANSLATE(
"\tsudo <your favorite text editor> /etc/grub.d/40_custom\n\n");
infoText << B_TRANSLATE(
"GRUB's naming scheme for partitions is: (hdN,n)\n\n");
infoText << B_TRANSLATE(
"All hard disks start with \"hd\".\n");
infoText << B_TRANSLATE(
"\"N\" is the hard disk number, starting with \"0\".\n");
infoText << B_TRANSLATE(
"\"n\" is the partition number, which for GRUB 2 starts with \"1\"\n");
infoText << B_TRANSLATE(
"With GRUB 2 the first logical partition always has the number \"5\", "
"regardless of the number of primary partitions.\n\n");
infoText << B_TRANSLATE(
"So below the heading that must not be edited, add something similar "
"to these lines:\n\n");
infoText << B_TRANSLATE(
"\t# Haiku on /dev/sda7\n");
infoText << B_TRANSLATE(
"\tmenuentry \"Haiku Alpha\" {\n");
infoText << B_TRANSLATE(
"\t\tset root=(hd0,7)\n");
infoText << B_TRANSLATE(
"\t\tchainloader +1\n");
infoText << B_TRANSLATE(
"\t}\n\n");
infoText << B_TRANSLATE(
"Additionally you have to edit another file to actually display the "
"boot menu:\n\n");
infoText << B_TRANSLATE(
"\tsudo <your favorite text editor> /etc/default/grub\n\n");
infoText << B_TRANSLATE(
"Here you have to comment out the line \"GRUB_HIDDEN_TIMEOUT=0\" by "
"putting a \"#\" in front of it in order to actually display the "
"boot menu.\n\n");
infoText << B_TRANSLATE(
"Finally, you have to update the boot menu by entering:\n\n");
infoText << B_TRANSLATE(
"\tsudo update-grub\n\n\n");
infoText << B_TRANSLATE(
"3) When you successfully boot into Haiku for the first time, make "
"sure to read our \"Welcome\" and \"Userguide\" documentation. There "
"are links on the Desktop and in WebPositive's bookmarks.\n\n");
infoText << B_TRANSLATE(
"Have fun and thanks a lot for trying out Haiku! We hope you like it!");
BTextView* textView = new BTextView("eula", be_plain_font, NULL, B_WILL_DRAW);
textView->SetInsets(10, 10, 10, 10);
textView->MakeEditable(false);
textView->MakeSelectable(false);
textView->SetText(infoText);
BScrollView* scrollView = new BScrollView("eulaScroll",
textView, B_WILL_DRAW, false, true);
BButton* cancelButton = new BButton(B_TRANSLATE("Quit"),
new BMessage(B_QUIT_REQUESTED));
cancelButton->SetTarget(be_app);
BButton* continueButton = new BButton(B_TRANSLATE("Continue"),
new BMessage(kMsgAgree));
continueButton->SetTarget(be_app);
continueButton->MakeDefault(true);
if (!be_roster->IsRunning(kTrackerSignature))
SetWorkspaces(B_ALL_WORKSPACES);
BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_DEFAULT_SPACING)
.SetInsets(B_USE_WINDOW_SPACING)
.Add(scrollView)
.AddGroup(B_HORIZONTAL, B_USE_ITEM_SPACING)
.AddGlue()
.Add(cancelButton)
.Add(continueButton);
CenterOnScreen();
Show();
}