BStringView* InfoWin::_CreateLabel(const char* name, const char* label) { static const rgb_color kLabelColor = tint_color( ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT); BStringView* view = new BStringView(name, label); view->SetAlignment(B_ALIGN_RIGHT); view->SetHighColor(kLabelColor); return view; }
BView * LibraryWindow::AddHeader(BPoint location, const char *label) { Lock(); BRect r(location.x,location.y,location.x + 1, location.y + 1); BStringView *header = new BStringView(r,"header",label); fCheckList->AddChild(header); header->SetFont(be_bold_font); header->SetHighColor(0,0,255); header->ResizeToPreferred(); Unlock(); return header; }
void MediaWindow::_MakeEmptyParamView() { fParamWeb = NULL; BStringView* stringView = new BStringView("noControls", B_TRANSLATE("This hardware has no controls.")); BSize unlimited(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED); stringView->SetExplicitMaxSize(unlimited); BAlignment centered(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER); stringView->SetExplicitAlignment(centered); stringView->SetAlignment(B_ALIGN_CENTER); fContentLayout->AddView(stringView); fContentLayout->SetVisibleItem(fContentLayout->CountItems() - 1); rgb_color panel = stringView->LowColor(); stringView->SetHighColor(tint_color(panel, B_DISABLED_LABEL_TINT)); }
void ChannelOptions::Init(void) { BString temp(S_CHANOPTS_TITLE); temp.Prepend(chan_name); SetTitle(temp.String()); bgView = new BView(Bounds(), "Background", B_FOLLOW_ALL_SIDES, B_WILL_DRAW); bgView->AdoptSystemColors(); AddChild(bgView); BStringView* tempStringView = new BStringView(Bounds(), "temp", "AEIOUglqj", 0, 0); tempStringView->ResizeToPreferred(); float stringHeight = tempStringView->Frame().bottom; delete tempStringView; privilegesView = new BView(BRect(bgView->Frame().left + 2, bgView->Frame().top + 2, bgView->Frame().right - 2, stringHeight + 2), "privilege message", 0, B_WILL_DRAW); privilegesView->SetViewColor(0, 100, 0); bgView->AddChild(privilegesView); BString privString; // this will become dynamic based on the current mode privString += S_CHANOPTS_OPID1; privString += S_CHANOPTS_OPID2; BStringView* privMsgView = new BStringView(BRect(privilegesView->Bounds().left, privilegesView->Bounds().top, privilegesView->Bounds().right, stringHeight), "privMsgView", privString.String(), 0, B_WILL_DRAW); privMsgView->SetHighColor(255, 255, 255); privMsgView->SetAlignment(B_ALIGN_CENTER); privilegesView->ResizeToPreferred(); privilegesView->AddChild(privMsgView); }
HighScores::HighScores(Hall& H, BMessage *m, BLooper *l): BWindow(BRect(100, 100, 820, 500), "BShisen High Scores", B_TITLED_WINDOW, B_NOT_RESIZABLE | /*B_NOT_CLOSABLE |*/ B_NOT_ZOOMABLE) { BView *back; BListView *LV; BScrollView *SV; BRect r; BStringView *str; loop = l; msg = m; back = new BView(Bounds(), "BackGround", B_FOLLOW_ALL, B_WILL_DRAW); back->SetViewColor(216, 216, 216); AddChild(back); str = new BStringView(BRect(10, 10, 190, 25), "", "Name"); str->SetHighColor(0, 0, 0); str->SetFontSize(14); str->SetFont(be_bold_font); back->AddChild(str); str = new BStringView(BRect(200, 10, 290, 25), "", "Time"); str->SetHighColor(0, 0, 0); str->SetFontSize(14); str->SetFont(be_bold_font); back->AddChild(str); str = new BStringView(BRect(300, 10, 390, 25), "", "Game Size"); str->SetHighColor(0, 0, 0); str->SetFontSize(14); str->SetFont(be_bold_font); back->AddChild(str); str = new BStringView(BRect(400, 10, 490, 25), "", "Game Number"); str->SetHighColor(0, 0, 0); str->SetFontSize(14); str->SetFont(be_bold_font); back->AddChild(str); str = new BStringView(BRect(500, 10, 590, 25), "", "Date"); str->SetHighColor(0, 0, 0); str->SetFontSize(14); str->SetFont(be_bold_font); back->AddChild(str); str = new BStringView(BRect(600, 10, 720, 25), "", "Tiles Per Minute"); str->SetHighColor(0, 0, 0); str->SetFontSize(14); str->SetFont(be_bold_font); back->AddChild(str); r = Bounds(); r.right -= 14; r.top += 30; LV = new BListView(r, ""); SV = new BScrollView("", LV, B_FOLLOW_ALL, 0, false, true); LV->AddList(H.List); LV->AddList(H.List1); LV->AddList(H.List2); LV->AddList(H.List3); LV->AddList(H.List4); LV->AddList(H.List5); back->AddChild(SV); }
InfoWin::InfoWin(BPoint p, FileInfo *f, BWindow* parent) : BWindow(BRect(p, p), kEmptyStr, B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE) { AddToSubset(parent); typedef pair<string, string> Item; typedef vector<Item> InfoList; char name[B_PATH_NAME_LENGTH]; strcpy(name, f->ref.name); strcat(name, " info"); SetTitle(name); InfoList info; Item item; // Size size_to_string(f->size, name); if (f->count > 0) { // This is a directory. char str[64]; sprintf(str, kInfoInFiles, f->count); strcat(name, str); } info.push_back(Item(kInfoSize, name)); // Created & modified dates BEntry entry(&f->ref); time_t t; entry.GetCreationTime(&t); strftime(name, 64, kInfoTimeFmt, localtime(&t)); info.push_back(Item(kInfoCreated, name)); entry.GetModificationTime(&t); strftime(name, 64, kInfoTimeFmt, localtime(&t)); info.push_back(Item(kInfoModified, name)); // Kind BMimeType* type = f->Type(); type->GetShortDescription(name); info.push_back(Item(kInfoKind, name)); delete type; // Path string path; f->GetPath(path); info.push_back(Item(kInfoPath, path)); // Icon BBitmap *icon = new BBitmap(BRect(0.0, 0.0, 31.0, 31.0), B_RGBA32); entry_ref ref; entry.GetRef(&ref); BNodeInfo::GetTrackerIcon(&ref, icon, B_LARGE_ICON); // Compute the window size and add the views. BFont smallFont(be_plain_font); smallFont.SetSize(floorf(smallFont.Size() * 0.95)); struct font_height fh; smallFont.GetHeight(&fh); float fontHeight = fh.ascent + fh.descent + fh.leading; float leftWidth = 32.0; float rightWidth = 0.0; InfoList::iterator i = info.begin(); while (i != info.end()) { float w = smallFont.StringWidth((*i).first.c_str()) + 2.0 * kSmallHMargin; leftWidth = max_c(leftWidth, w); w = smallFont.StringWidth((*i).second.c_str()) + 2.0 * kSmallHMargin; rightWidth = max_c(rightWidth, w); i++; } float winHeight = 32.0 + 4.0 * kSmallVMargin + 5.0 * (fontHeight + kSmallVMargin); float winWidth = leftWidth + rightWidth; ResizeTo(winWidth, winHeight); LeftView *leftView = new LeftView(BRect(0.0, 0.0, leftWidth, winHeight), icon); BView *rightView = new BView( BRect(leftWidth + 1.0, 0.0, winWidth, winHeight), NULL, B_FOLLOW_NONE, B_WILL_DRAW); AddChild(leftView); AddChild(rightView); BStringView *sv = new BStringView( BRect(kSmallHMargin, kSmallVMargin, rightView->Bounds().Width(), kSmallVMargin + 30.0), NULL, f->ref.name, B_FOLLOW_ALL); BFont largeFont(be_plain_font); largeFont.SetSize(ceilf(largeFont.Size() * 1.1)); sv->SetFont(&largeFont); rightView->AddChild(sv); float y = 32.0 + 4.0 * kSmallVMargin; i = info.begin(); while (i != info.end()) { sv = new BStringView( BRect(kSmallHMargin, y, leftView->Bounds().Width(), y + fontHeight), NULL, (*i).first.c_str()); sv->SetFont(&smallFont); sv->SetAlignment(B_ALIGN_RIGHT); sv->SetHighColor(kBasePieColor[1]); // arbitrary leftView->AddChild(sv); sv = new BStringView( BRect(kSmallHMargin, y, rightView->Bounds().Width(), y + fontHeight), NULL, (*i).second.c_str()); sv->SetFont(&smallFont); rightView->AddChild(sv); y += fontHeight + kSmallVMargin; i++; } Show(); }
// constructor NavigationInfoPanel::NavigationInfoPanel(BWindow* parent, const BMessage& message, const BMessenger& target) : BWindow(BRect(0, 0, 200, 30), "Navigation Info", B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE) , fMessage(message) , fTarget(target) { // create the interface and resize to fit BRect frame = Bounds(); frame.InsetBy(5, 5); frame.bottom = frame.top + 15; // label string view fLabelView = new BStringView(frame, "label", kLabel, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); fLabelView->ResizeToPreferred(); frame = fLabelView->Frame(); // target clip text control frame.OffsetBy(0, frame.Height() + 5); fTargetClipTC = new BTextControl(frame, "clip id", "Target Playlist ID", "", new BMessage(MSG_INVOKE), B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT); fTargetClipTC->ResizeToPreferred(); frame = fTargetClipTC->Frame(); // help string view frame.OffsetBy(0, frame.Height() + 5); BStringView* helpView = new BStringView(frame, "help", "Drag and drop a playlist clip here.", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); BFont font; helpView->GetFont(&font); font.SetFace(B_ITALIC_FACE); font.SetSize(font.Size() * 0.9); helpView->SetFont(&font); helpView->SetAlignment(B_ALIGN_CENTER); helpView->ResizeToPreferred(); // parent view frame = fLabelView->Frame() | fTargetClipTC->Frame() | helpView->Frame(); frame.InsetBy(-5, -5); fInfoView = new InfoView(frame, this); fInfoView->AddChild(fLabelView); fInfoView->AddChild(fTargetClipTC); fInfoView->AddChild(helpView); // resize to fit and adjust size limits ResizeTo(fInfoView->Frame().Width(), fInfoView->Frame().Height()); AddChild(fInfoView); float minWidth, maxWidth, minHeight, maxHeight; GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight); minWidth = Frame().Width(); minHeight = maxHeight = Frame().Height(); SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight); // modify the high color after the help view is attached to a window helpView->SetHighColor(tint_color(helpView->LowColor(), B_DISABLED_LABEL_TINT)); helpView->SetFlags(helpView->Flags() | B_FULL_UPDATE_ON_RESIZE); // help the buggy BeOS BStringView (when text alignment != left...) fInfoView->SetEventMask(B_POINTER_EVENTS); // resize controls to the same (maximum) width float maxControlWidth = fLabelView->Frame().Width(); maxControlWidth = max_c(maxControlWidth, fTargetClipTC->Frame().Width()); maxControlWidth = max_c(maxControlWidth, helpView->Frame().Width()); fLabelView->ResizeTo(maxControlWidth, fLabelView->Frame().Height()); fTargetClipTC->ResizeTo(maxControlWidth, fTargetClipTC->Frame().Height()); helpView->ResizeTo(maxControlWidth, helpView->Frame().Height()); // center above parent window BAutolock _(parent); frame = Frame(); BRect parentFrame = parent->Frame(); MoveTo((parentFrame.left + parentFrame.right - frame.Width()) / 2, (parentFrame.top + parentFrame.bottom - frame.Height()) / 2); AddToSubset(parent); }
void Shisen::AboutRequested(void) { BWindow *about = NULL; thread_id id; id = find_thread("w>About BShisen"); if (id != B_NAME_NOT_FOUND) { about = (BWindow *)LooperForThread(id); } if (about) { about->SetWorkspaces(B_CURRENT_WORKSPACE); about->Activate(); } else { BView *back; BStringView *str; BBitmap *bmap; about = new BWindow(BRect(50, 50, 360, 190), _("ABOUT_BSHISEN","About BShisen"), B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE); back = new BView(about->Bounds(), NULL, B_FOLLOW_NONE, B_WILL_DRAW); back->SetViewColor(0, 0, 0); //black background about->AddChild(back); str = new BStringView(BRect(100, 10, 310, 30), NULL, "BShisen 1.5.0-alpha"); str->SetFontSize(14); str->SetHighColor(0,255,0); back->AddChild(str); str = new BStringView(BRect(100, 35, 310, 55), NULL, "(c) 1999-2014 Kelvin W Sherlock" ); str->SetFontSize(12); str->SetHighColor(0,255,0); back->AddChild(str); str = new BStringView(BRect(100, 60, 310, 80), NULL, "Maintainer: [email protected]"); str->SetFontSize(10); str->SetHighColor(0,255,0); back->AddChild(str); #if BUILD == SHAREWARE if (!REGISTERED) //70, 90 { str = new BStringView(BRect(30, 85, 310, 105), NULL, "UNREGISTERED - PLEASE REGISTER"); str->SetFontSize(12); str->SetHighColor(255,0,0); back->AddChild(str); } #endif #if BUILD == BEGROOVY { str = new BStringView(BRect(100, 95, 310, 110), NULL, "Get your groove on - BeGroovy"); str->SetFontSize(12); str->SetHighColor(255,0,0); back->AddChild(str); str = new BStringView(BRect(100, 110, 310, 130), NULL, "www.BeGroovy.com"); str->SetFontSize(14); str->SetHighColor(255,0,0); back->AddChild(str); } #endif #if BUILD == CUSTOM { str = new BStringView(BRect(100, 95, 310, 110), NULL, B_UTF8_OPEN_QUOTE "It's the same train, but it's different."B_UTF8_CLOSE_QUOTE); str->SetFontSize(10); str->SetHighColor(255,0,0); back->AddChild(str); str = new BStringView(BRect(100, 110, 310, 130), NULL, B_UTF8_OPEN_QUOTE "Based on 1.2pre sources (Released 2014)" B_UTF8_CLOSE_QUOTE); str->SetFontSize(10); str->SetHighColor(255,0,0); back->AddChild(str); } #endif // Pistooli: Again too lazy to search for ABOUT_PIC_ID, put TIFF into Resource File bmap = BTranslationUtils::GetBitmap(B_TIFF_FORMAT, 1); // bmap = BTranslationUtils::GetBitmap(B_RAW_TYPE, ABOUT_PIC_ID); if (bmap) { back->SetViewBitmap(bmap, B_FOLLOW_ALL, 0); free(bmap); } about->Flush(); about->Show(); } /* Add window controls */ }
InfoWin::InfoWin(BPoint p, FileInfo *f, BWindow* parent) : BWindow(BRect(p, p), kEmptyStr, B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE) { AddToSubset(parent); typedef pair<string, string> Item; typedef vector<Item> InfoList; BString stringTitle("%refName% info"); stringTitle.ReplaceFirst("%refName%", f->ref.name); SetTitle(stringTitle.String()); InfoList info; Item item; // Size BString name; if (f->count > 0) { // This is a directory, include file count information static BMessageFormat format(B_TRANSLATE( "%size% in {0, plural, one{# file} other{# files}}")); format.Format(name, f->count); } else name = "%size%"; char tmp[B_PATH_NAME_LENGTH] = { 0 }; string_for_size(f->size, tmp, sizeof(tmp)); name.ReplaceFirst("%size%", tmp); info.push_back(Item(B_TRANSLATE_MARK("Size"), name.String())); // Created & modified dates BEntry entry(&f->ref); time_t t; entry.GetCreationTime(&t); strftime(tmp, 64, B_TRANSLATE("%a, %d %b %Y, %r"), localtime(&t)); info.push_back(Item(B_TRANSLATE("Created"), tmp)); entry.GetModificationTime(&t); strftime(tmp, 64, B_TRANSLATE("%a, %d %b %Y, %r"), localtime(&t)); info.push_back(Item(B_TRANSLATE("Modified"), tmp)); // Kind BMimeType* type = f->Type(); type->GetShortDescription(tmp); info.push_back(Item(B_TRANSLATE("Kind"), tmp)); delete type; // Path string path; f->GetPath(path); info.push_back(Item(B_TRANSLATE("Path"), path)); // Icon BBitmap *icon = new BBitmap(BRect(0.0, 0.0, 31.0, 31.0), B_RGBA32); entry_ref ref; entry.GetRef(&ref); BNodeInfo::GetTrackerIcon(&ref, icon, B_LARGE_ICON); // Compute the window size and add the views. BFont smallFont(be_plain_font); smallFont.SetSize(floorf(smallFont.Size() * 0.95)); struct font_height fh; smallFont.GetHeight(&fh); float fontHeight = fh.ascent + fh.descent + fh.leading; float leftWidth = 32.0; float rightWidth = 0.0; InfoList::iterator i = info.begin(); while (i != info.end()) { float w = smallFont.StringWidth((*i).first.c_str()) + 2.0 * kSmallHMargin; leftWidth = max_c(leftWidth, w); w = smallFont.StringWidth((*i).second.c_str()) + 2.0 * kSmallHMargin; rightWidth = max_c(rightWidth, w); i++; } float winHeight = 32.0 + 4.0 * kSmallVMargin + 5.0 * (fontHeight + kSmallVMargin); float winWidth = leftWidth + rightWidth; ResizeTo(winWidth, winHeight); LeftView *leftView = new LeftView(BRect(0.0, 0.0, leftWidth, winHeight), icon); BView *rightView = new BView( BRect(leftWidth + 1.0, 0.0, winWidth, winHeight), NULL, B_FOLLOW_NONE, B_WILL_DRAW); AddChild(leftView); AddChild(rightView); BStringView *sv = new BStringView( BRect(kSmallHMargin, kSmallVMargin, rightView->Bounds().Width(), kSmallVMargin + 30.0), NULL, f->ref.name, B_FOLLOW_ALL); BFont largeFont(be_plain_font); largeFont.SetSize(ceilf(largeFont.Size() * 1.1)); sv->SetFont(&largeFont); rightView->AddChild(sv); float y = 32.0 + 4.0 * kSmallVMargin; i = info.begin(); while (i != info.end()) { sv = new BStringView( BRect(kSmallHMargin, y, leftView->Bounds().Width(), y + fontHeight), NULL, (*i).first.c_str()); sv->SetFont(&smallFont); sv->SetAlignment(B_ALIGN_RIGHT); sv->SetHighColor(kBasePieColor[1]); // arbitrary leftView->AddChild(sv); sv = new BStringView( BRect(kSmallHMargin, y, rightView->Bounds().Width(), y + fontHeight), NULL, (*i).second.c_str()); sv->SetFont(&smallFont); rightView->AddChild(sv); y += fontHeight + kSmallVMargin; i++; } Show(); }