本文整理汇总了C++中BStringView::SetText方法的典型用法代码示例。如果您正苦于以下问题:C++ BStringView::SetText方法的具体用法?C++ BStringView::SetText怎么用?C++ BStringView::SetText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BStringView
的用法示例。
在下文中一共展示了BStringView::SetText方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BAlert
void
Window::MessageReceived(BMessage* message)
{
switch (message->what) {
case kMsgShowAlert:
{
int32 count = fCountSlider->Value();
BAlert* alert = new BAlert("Test title", "Lorem ipsum dolor sit "
"amet, consectetur adipiscing elit. Suspendisse vel iaculis "
"quam. Donec faucibus erat nunc, ac ullamcorper justo sodales.",
"short 1", count > 1 ? "a bit longer 2" : NULL,
count > 2 ? "very very long button 3" : NULL,
_ButtonWidth(), _ButtonSpacing(), _AlertType());
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
int result = alert->Go();
if (result < 0) {
fLastStringView->SetText("Canceled alert");
} else {
fLastStringView->SetText(BString().SetToFormat(
"Pressed button %d", result + 1).String());
}
break;
}
default:
BWindow::MessageReceived(message);
}
}
示例2:
status_t
AboutView::SetVersion(const char* version)
{
fVersionView->SetText(version);
return B_OK;
}
示例3: Display
void Display()
{
BString count;
FormatCountString(&count, totalFiles_, totalDirs_, totalBytes_);
mTotalCount_->SetText(count.String());
if (markedDirs_ > 0 || markedFiles_ > 0) {
FormatCountString(&count, markedFiles_, markedDirs_, markedBytes_);
count << " Marked";
} else {
count.SetTo("");
}
mMarkedCount_->SetText(count.String());
Invalidate();
}
示例4:
void
TeamDescriptionView::SetItem(TeamListItem* item)
{
fItem = item;
if (item == NULL) {
int32 styleStart = 0;
int32 styleEnd = 0;
BString text;
text.SetToFormat(fInfoString, fSeconds);
fInfoTextView->SetText(text);
if (fRebootRunner != NULL && fSeconds < 4) {
styleStart = text.FindLast('\n');
styleEnd = text.Length();
}
if (styleStart != styleEnd && fInfoTextView != NULL) {
BFont font;
fInfoTextView->GetFont(&font);
font.SetFace(B_BOLD_FACE);
fInfoTextView->SetStylable(true);
fInfoTextView->SetFontAndColor(styleStart, styleEnd, &font);
}
} else {
fTeamName->SetText(item->Path()->Path());
if (item->IsSystemServer()) {
if (fSysComponent->IsHidden(fSysComponent))
fSysComponent->Show();
} else {
if (!fSysComponent->IsHidden(fSysComponent))
fSysComponent->Hide();
}
if (item->IsRefusingToQuit()) {
if (fQuitOverdue->IsHidden(fQuitOverdue))
fQuitOverdue->Show();
} else {
if (!fQuitOverdue->IsHidden(fQuitOverdue))
fQuitOverdue->Hide();
}
fIconView->SetIcon(item->Path()->Path());
}
if (fLayout == NULL)
return;
if (item == NULL)
fLayout->SetVisibleItem((int32)0);
else
fLayout->SetVisibleItem((int32)1);
Invalidate();
}
示例5: str
status_t
PLabel::SetProperty(const char *name, PValue *value, const int32 &index)
{
if (!name || !value)
return B_ERROR;
BString str(name);
PProperty *prop = FindProperty(name,index);
if (!prop)
return B_NAME_NOT_FOUND;
if (FlagsForProperty(prop) & PROPERTY_READ_ONLY)
return B_READ_ONLY;
BStringView *backend = (BStringView*)fView;
BoolValue boolval;
CharValue charval;
ColorValue colorval;
FloatValue floatval;
IntValue intval;
PointValue pointval;
RectValue rectval;
StringValue stringval;
status_t status = prop->SetValue(value);
if (status != B_OK)
return status;
if (backend->Window())
backend->Window()->Lock();
if (str.ICompare("Alignment") == 0)
{
prop->GetValue(&intval);
backend->SetAlignment((alignment)*intval.value);
}
else if (str.ICompare("Text") == 0)
{
prop->GetValue(&stringval);
backend->SetText(*stringval.value);
}
else
{
if (backend->Window())
backend->Window()->Unlock();
return PView::SetProperty(name, value, index);
}
if (backend->Window())
backend->Window()->Unlock();
return prop->GetValue(value);
}
示例6: 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);
}
}
示例7: pulsehits
status_t CharismaWindow::pulsehits()
{
int hits0,hits1;
char s[40];
hits1=-1;
for(;;){
snooze(100000);
hits0=hitcount;
if(hits0!=hits1){
sprintf(s,"Hits: %d",hitcount);
Lock();
hits->SetText(s);
Unlock();
}
hits1=hits0;
}
return 0;
}
示例8: if
void
BBox::SetLabel(const char *label)
{
if (!(label == NULL || *label == 0)) {
BStringView *strView = cast_as(fLabelView, BStringView);
if (strView != NULL) {
strView->SetText(label);
strView->ResizeToPreferred();
ReAdjustLabel();
return;
}
if ((strView = new BStringView(BRect(0, 0, 1, 1), NULL, label, B_FOLLOW_NONE)) == NULL) return;
strView->SetFont(be_bold_font);
strView->ResizeToPreferred();
if (SetLabel(strView) != B_OK) delete strView;
} else if (fLabelView != NULL) {
BView *view = fLabelView;
fLabelView = NULL;
view->RemoveSelf();
delete view;
}
}
示例9: title
LibraryWindow::LibraryWindow(BRect frame, const BMessenger &parent, Project *project)
: DWindow(frame,NULL,B_TITLED_WINDOW,B_ASYNCHRONOUS_CONTROLS |
B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE),
fParent(parent),
fProject(project)
{
if (project)
{
BString title(TR("Libraries: "));
title << project->GetName();
SetTitle(title.String());
}
BView *top = GetBackgroundView();
BRect r(10,10,11,11);
BStringView *label = new BStringView(r,"label",TR("Choose the system libraries "
"for your project."));
label->ResizeToPreferred();
top->AddChild(label);
label->SetText(TR("Scanning libraries…"));
r = Bounds().InsetByCopy(10,10);
r.top = label->Frame().top + 20;
r.right -= B_V_SCROLL_BAR_WIDTH;
fCheckList = new BView(r,"checklist",B_FOLLOW_ALL,B_WILL_DRAW);
BScrollView *scrollView = new BScrollView("scrollView",fCheckList,
B_FOLLOW_ALL, 0,false,true);
top->AddChild(scrollView);
fScanThread = spawn_thread(ScanThread,"libscanthread",B_NORMAL_PRIORITY,this);
resume_thread(fScanThread);
fCheckList->MakeFocus(true);
}
示例10: MessageReceived
void MonthWindowView::MessageReceived(BMessage *msg)
{
switch(msg->what)
{
case 'YEA0': // year before
{
if(cyear<=first_year) break;
cyear--;
NewMonth=true;
BString s("");
if(cyear<10) s.Append("000");
else if(cyear<100) s.Append("00");
else if(cyear<1000) s.Append("0");
s<<cyear;
yearStringView->SetText(s.String());
if(cmonth==2) if(cday==29) // one can do simplier: if cday==29, then make
// cday=28, because two leap years one after other can't be
{
if(cyear%4!=0) cday=28;
else if(cyear%100==0 && cyear%400!=0) cday=28;
}
DrawMonth();
break;
}
case 'YEA1': // year after
{
if(cyear>=last_year) break;
cyear++;
NewMonth=true;
BString s("");
if(cyear<10) s.Append("000");
else if(cyear<100) s.Append("00");
else if(cyear<1000) s.Append("0");
s<<cyear;
yearStringView->SetText(s.String());
if(cmonth==2) if(cday==29)
{
if(cyear%4!=0) cday=28;
else if(cyear%100==0 && cyear%400!=0) cday=28;
}
DrawMonth();
break;
}
case 'MON0': // month before
{
if(cmonth>1) cmonth--;
else if(cyear>first_year)
{
cmonth=12;
cyear--;
BString s("");
if(cyear<10) s.Append("000");
else if(cyear<100) s.Append("00");
else if(cyear<1000) s.Append("0");
s<<cyear;
yearStringView->SetText(s.String());
}
else break; // nothing is changed
NewMonth=true;
monthStringView->SetText(monthNames[cmonth-1]);
if(cmonth==2)
{
int tmpday=28;
if(cyear%4==0) if((cyear%100!=0) || (cyear%400==0)) tmpday=29;
if(cday>tmpday) cday=tmpday;
}
else if(cday>monthDays[cmonth-1]) cday=monthDays[cmonth-1];
DrawMonth();
break;
}
case 'MON1': // month after
{
if(cmonth<12) cmonth++;
else if(cyear<last_year)
{
cmonth=1;
cyear++;
BString s("");
if(cyear<10) s.Append("000");
else if(cyear<100) s.Append("00");
else if(cyear<1000) s.Append("0");
s<<cyear;
yearStringView->SetText(s.String());
}
else break; // nothing is changed
NewMonth=true;
monthStringView->SetText(monthNames[cmonth-1]);
if(cmonth==2)
{
//.........这里部分代码省略.........
示例11: AttachedToWindow
//.........这里部分代码省略.........
case 12:
{
s.Append("декабря ");
break;
}
}
s<<tyear;
s.Append(" г.");
#else // localized, english and french
BString s("");
s<<tday;
s.Append(" ");
s.Append(monthNames[tmonth-1]);
s.Append(" ");
s<<tyear;
#endif
msng=new BMessenger(this);
todayStringView=new MouseSenseStringView(new BMessage('TODA'), msng,
BRect(10,10,100,100),"todayMStringViewAViX",
s.String());
AddChild(todayStringView);
todayStringView->ResizeToPreferred();
todayStringView->SetViewColor(VIEW_COLOR);
monthStringView=new BStringView(BRect(10,10,100,100),"monthStringViewAViX",
monthNames[8]);
monthStringView->SetAlignment(B_ALIGN_CENTER);
AddChild(monthStringView);
monthStringView->ResizeToPreferred();
monthStringView->SetText(monthNames[cmonth-1]);
monthStringView->SetViewColor(VIEW_COLOR);
s.SetTo("");
if(cyear<10) s.Append("000");
else if(cyear<100) s.Append("00");
else if(cyear<1000) s.Append("0");
s<<cyear;
yearStringView=new BStringView(BRect(10,10,100,100),"yearStringViewAViX",
"0000");
AddChild(yearStringView);
yearStringView->ResizeToPreferred();
yearStringView->SetText(s.String());
yearStringView->SetViewColor(VIEW_COLOR);
ResizeTo(w_cell*7+1,h_cell*7+3+16+yearStringView->Bounds().bottom+todayStringView->Bounds().bottom);
Window()->ResizeTo(Bounds().right, Bounds().bottom);
yearMStringView[0]=new MouseSenseStringView(new BMessage('YEA0'),msng,
BRect(10,10,100,100),
"yearMStringViewAViX0",
"<<");
AddChild(yearMStringView[0]);
yearMStringView[0]->ResizeToPreferred();
yearMStringView[0]->SetViewColor(VIEW_COLOR);
yearMStringView[1]=new MouseSenseStringView(new BMessage('YEA1'),msng,
BRect(10,10,100,100),
"yearMStringViewAViX1",
">>");
AddChild(yearMStringView[1]);
yearMStringView[1]->ResizeToPreferred();
示例12: locker
//.........这里部分代码省略.........
const char *type = B_TRANSLATE("Unknown type");
switch (fEditor.Type()) {
case B_MINI_ICON_TYPE:
case B_LARGE_ICON_TYPE:
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
case B_VECTOR_ICON_TYPE:
#endif
type = B_TRANSLATE("Icon");
break;
case B_PNG_FORMAT:
type = B_TRANSLATE("PNG format");
break;
case B_MESSAGE_TYPE:
type = B_TRANSLATE("Flattened bitmap");
break;
default:
break;
}
const char *colorSpace;
switch (fBitmap->ColorSpace()) {
case B_GRAY1:
case B_GRAY8:
colorSpace = B_TRANSLATE("Grayscale");
break;
case B_CMAP8:
colorSpace = B_TRANSLATE("8 bit palette");
break;
case B_RGB32:
case B_RGBA32:
case B_RGB32_BIG:
case B_RGBA32_BIG:
colorSpace = B_TRANSLATE("32 bit");
break;
case B_RGB15:
case B_RGBA15:
case B_RGB15_BIG:
case B_RGBA15_BIG:
colorSpace = B_TRANSLATE("15 bit");
break;
case B_RGB16:
case B_RGB16_BIG:
colorSpace = B_TRANSLATE("16 bit");
break;
default:
colorSpace = B_TRANSLATE("Unknown format");
break;
}
snprintf(buffer, sizeof(buffer), "%s, %g x %g, %s", type,
fBitmap->Bounds().Width() + 1, fBitmap->Bounds().Height() + 1,
colorSpace);
fDescriptionView->SetText(buffer);
} else
fDescriptionView->SetText(B_TRANSLATE_COMMENT("Could not read image",
"Image means here a picture file, not a disk image."));
// Update the view size to match the image and its description
float width, height;
fDescriptionView->GetPreferredSize(&width, &height);
fDescriptionView->ResizeTo(width, height);
BRect rect = fDescriptionView->Bounds();
if (fBitmap != NULL) {
BRect bounds = fBitmap->Bounds();
rect.bottom += bounds.Height() + 5;
if (fScaleSlider != NULL && rect.Width() < fScaleSlider->Bounds().Width())
rect.right = fScaleSlider->Bounds().right;
if (bounds.Width() > rect.Width())
rect.right = bounds.right;
// center description below the bitmap
fDescriptionView->MoveTo((rect.Width() - fDescriptionView->Bounds().Width()) / 2,
bounds.Height() + 5);
if (fScaleSlider != NULL) {
// center slider below description
rect.bottom += fScaleSlider->Bounds().Height() + 5;
fScaleSlider->MoveTo((rect.Width() - fScaleSlider->Bounds().Width()) / 2,
fDescriptionView->Frame().bottom + 5);
if (fScaleSlider->IsHidden())
fScaleSlider->Show();
}
} else if (fScaleSlider != NULL && !fScaleSlider->IsHidden())
fScaleSlider->Hide();
ResizeTo(rect.Width(), rect.Height());
if (Parent()) {
// center within parent view
BRect parentBounds = Parent()->Bounds();
MoveTo((parentBounds.Width() - rect.Width()) / 2,
(parentBounds.Height() - rect.Height()) / 2);
}
Invalidate();
// restore old view size
fEditor.SetViewSize(viewSize);
}
示例13: r
int32
LibraryWindow::ScanThread(void *data)
{
LibraryWindow *win = (LibraryWindow *)data;
float maxwidth;
BRect r(5,5,105,20);
BView *systemheader = win->AddHeader(r.LeftTop(),TR("System Libraries:"));
win->Lock();
r = systemheader->Frame();
win->Unlock();
maxwidth = r.right;
r.OffsetBy(0,r.Height() + 10);
DPath sysPath = GetSystemPath(B_USER_DEVELOP_DIRECTORY);
sysPath << "lib/x86";
BRect out = win->ScanFolder(r.LeftTop(),sysPath.GetFullPath(),&maxwidth);
if (out != BRect(0,0,-1,-1))
{
r = out;
r.OffsetBy(0,10);
}
if (gPlatform == PLATFORM_HAIKU || gPlatform == PLATFORM_HAIKU_GCC4)
{
BView *commonheader = win->AddHeader(r.LeftTop(),TR("Common Libraries:"));
win->Lock();
r = commonheader->Frame();
win->Unlock();
maxwidth = MAX(r.right,maxwidth);
r.OffsetBy(0,r.Height() + 10);
out = win->ScanFolder(r.LeftTop(),GetSystemPath(B_USER_LIB_DIRECTORY).GetFullPath(),
&maxwidth);
if (out != BRect(0,0,-1,-1))
{
r = out;
r.OffsetBy(0,10);
}
}
BView *userheader = win->AddHeader(r.LeftTop(),TR("User Libraries:"));
win->Lock();
r = userheader->Frame();
win->Unlock();
maxwidth = MAX(r.right,maxwidth);
r.OffsetBy(0,r.Height() + 10);
out = win->ScanFolder(r.LeftTop(),GetSystemPath(B_USER_LIB_DIRECTORY).GetFullPath(),
&maxwidth);
if (out.IsValid())
{
r = out;
r.OffsetBy(0,10);
}
win->Lock();
BView *top = win->GetBackgroundView();
BScrollView *scrollView = (BScrollView*)top->FindView("scrollView");
BScrollBar *vbar = scrollView->ScrollBar(B_VERTICAL);
vbar->SetRange(0, r.bottom - scrollView->Bounds().Height());
vbar->SetSteps(r.Height() * 2.0,r.Height() * 8.0);
gSettings.Lock();
BRect savedframe;
if (gSettings.FindRect("libwin_frame",&savedframe) == B_OK)
win->ResizeTo(savedframe.Width(),savedframe.Height());
gSettings.Unlock();
BStringView *label = (BStringView*)top->FindView("label");
label->SetText(TR("Choose the system libraries for your project."));
float minw = label->Frame().right + 10;
win->SetSizeLimits(minw,30000,200,30000);
if (win->Bounds().Width() < minw)
win->ResizeTo(minw,win->Bounds().Height());
win->fScanThread = -1;
win->Unlock();
return 0;
}
示例14: MessageReceived
void CharismaWindow::MessageReceived(BMessage *message)
{
char buf[B_PATH_NAME_LENGTH+1024];
BWindow *w;
entry_ref ref;
BEntry entry;
BPath path;
switch (message->what){
case kMsg_About:
about();
break;
case kMsg_SelectDirectory:
w=selectdirpanel->Window();
w->Lock();
sprintf(buf,"Current: %s",g_webdir);
currentdir->SetText(buf);
w->Unlock();
selectdirpanel->Show();
break;
case kMsg_DirSelected:
if(message->FindRef("refs", 0, &ref)) break;
entry.SetTo(&ref);
entry.GetPath(&path);
sprintf(g_webdir,"%s/",path.Path());
sprintf(buf,
"The new Web directory is: %s\n"
"If you wish to use previously acquired data, you should move or copy them here.\n"
"This modification will take effect for Stamina when Stamina is re-launched.",
g_webdir);
message->FindRef("refs",&ref);
(new BAlert("Charisma message",buf,"OK"))->Go();
saveprefs();
break;
case kMsg_ExternalControl:
extcontrol_item->SetMarked(!extcontrol_item->IsMarked());
update_proxy_settings();
break;
case kMsg_NetposAutosettings:
netposautoset_item->SetMarked(!netposautoset_item->IsMarked());
setnetpos();
break;
case kMsg_ClearHits:
hitcount=0;
break;
case kMsg_ProxySettings:
update_proxy_settings();
setnetpos();
break;
default:
BWindow::MessageReceived(message);
break;
}
}