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; }
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(); }
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!" }
void Leaves::StartConfig(BView* view) { BRect bounds = view->Bounds(); bounds.InsetBy(10, 10); BRect frame(0, 0, bounds.Width(), 20); fDropRateSlider = new BSlider(frame, "drop rate", B_TRANSLATE("Drop rate:"), new BMessage(MSG_SET_DROP_RATE), kMinimumDropRate, kMaximumDropRate, B_BLOCK_THUMB, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM); fDropRateSlider->SetValue(fDropRate); fDropRateSlider->ResizeToPreferred(); bounds.bottom -= fDropRateSlider->Bounds().Height() * 1.5; fDropRateSlider->MoveTo(bounds.LeftBottom()); view->AddChild(fDropRateSlider); fLeafSizeSlider = new BSlider(frame, "leaf size", B_TRANSLATE("Leaf size:"), new BMessage(MSG_SET_LEAF_SIZE), kMinimumLeafSize, kMaximumLeafSize, B_BLOCK_THUMB, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM); fLeafSizeSlider->SetValue(fLeafSize); fLeafSizeSlider->ResizeToPreferred(); bounds.bottom -= fLeafSizeSlider->Bounds().Height() * 1.5; fLeafSizeSlider->MoveTo(bounds.LeftBottom()); view->AddChild(fLeafSizeSlider); fSizeVariationSlider = new BSlider(frame, "variation", B_TRANSLATE("Size variation:"), new BMessage(MSG_SET_SIZE_VARIATION), 0, kMaximumSizeVariation, B_BLOCK_THUMB, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM); fSizeVariationSlider->SetValue(fSizeVariation); fSizeVariationSlider->ResizeToPreferred(); bounds.bottom -= fSizeVariationSlider->Bounds().Height() * 1.5; fSizeVariationSlider->MoveTo(bounds.LeftBottom()); view->AddChild(fSizeVariationSlider); BTextView* textView = new BTextView(bounds, B_EMPTY_STRING, bounds.OffsetToCopy(0., 0.), B_FOLLOW_ALL, B_WILL_DRAW); textView->SetViewColor(view->ViewColor()); BString name = B_TRANSLATE("Leaves"); BString text = name; text << "\n\n"; text << B_TRANSLATE("by Deyan Genovski, Geoffry Song"); text << "\n\n"; textView->Insert(text.String()); textView->SetStylable(true); textView->SetFontAndColor(0, name.Length(), be_bold_font); textView->MakeEditable(false); view->AddChild(textView); BWindow* window = view->Window(); if (window) window->AddHandler(this); fDropRateSlider->SetTarget(this); fLeafSizeSlider->SetTarget(this); fSizeVariationSlider->SetTarget(this); }
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(); }
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; }
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(); }
SGIView::SGIView(const char* name, uint32 flags, TranslatorSettings* settings) : BView(name, flags, new BGroupLayout(B_VERTICAL)), fSettings(settings) { BPopUpMenu* menu = new BPopUpMenu("pick compression"); uint32 currentCompression = fSettings->SetGetInt32(SGI_SETTING_COMPRESSION); // create the menu items with the various compression methods add_menu_item(menu, SGI_COMP_NONE, B_TRANSLATE("None"), currentCompression); //menu->AddSeparatorItem(); add_menu_item(menu, SGI_COMP_RLE, B_TRANSLATE("RLE"), currentCompression); // DON'T turn this on, it's so slow that I didn't wait long enough // the one time I tested this. So I don't know if the code even works. // Supposedly, this would look for an already written scanline, and // modify the scanline tables so that the current row is not written // at all... //add_menu_item(menu, SGI_COMP_ARLE, "Agressive RLE", currentCompression); fCompressionMF = new BMenuField("compression", B_TRANSLATE("Use compression:"), menu); BAlignment labelAlignment(B_ALIGN_LEFT, B_ALIGN_NO_VERTICAL); BStringView* titleView = new BStringView("title", B_TRANSLATE("SGI image translator")); titleView->SetFont(be_bold_font); titleView->SetExplicitAlignment(labelAlignment); char detail[100]; sprintf(detail, B_TRANSLATE("Version %d.%d.%d %s"), static_cast<int>(B_TRANSLATION_MAJOR_VERSION(SGI_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_MINOR_VERSION(SGI_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_REVISION_VERSION( SGI_TRANSLATOR_VERSION)), __DATE__); BStringView* detailView = new BStringView("details", detail); detailView->SetExplicitAlignment(labelAlignment); BTextView* infoView = new BTextView("info"); infoView->SetText(BString(B_TRANSLATE("written by:\n")) .Append(author) .Append(B_TRANSLATE("\n\nbased on GIMP SGI plugin v1.5:\n")) .Append(kSGICopyright).String()); infoView->SetExplicitAlignment(labelAlignment); infoView->SetWordWrap(false); infoView->MakeEditable(false); infoView->MakeResizable(true); infoView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); float padding = 5.0f; BLayoutBuilder::Group<>(this, B_VERTICAL, padding) .SetInsets(padding) .Add(titleView) .Add(detailView) .AddGroup(B_HORIZONTAL) .Add(fCompressionMF) .AddGlue() .End() .Add(infoView) .AddGlue(); BFont font; GetFont(&font); SetExplicitPreferredSize(BSize((font.Size() * 390) / 12, (font.Size() * 180) / 12)); // TODO: remove this workaround for ticket #4217 infoView->SetExplicitPreferredSize( BSize(infoView->LineWidth(4), infoView->TextHeight(0, 80))); infoView->SetExplicitMaxSize(infoView->ExplicitPreferredSize()); infoView->SetExplicitMinSize(infoView->ExplicitPreferredSize()); }
void ConfigWindow::MakeHowToView() { #ifndef HAIKU_TARGET_PLATFORM_HAIKU BResources *resources = BApplication::AppResources(); if (resources) { size_t length; char *buffer = (char *)resources->FindResource(B_LARGE_ICON_TYPE, 101, &length); if (buffer) { BBitmap *bitmap = new (nothrow) 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 < (int32)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; } } #else 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; } } #endif // HAIKU_TARGET_PLATFORM_HAIKU 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); static_cast<CenterContainer *>(fConfigView)->Layout(); }
FadeView::FadeView(const char* name, ScreenSaverSettings& settings) : BView(name, B_WILL_DRAW), fSettings(settings) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); font_height fontHeight; be_plain_font->GetHeight(&fontHeight); float textHeight = ceilf(fontHeight.ascent + fontHeight.descent); fEnableCheckBox = new BCheckBox("EnableCheckBox", B_TRANSLATE("Enable screensaver"), new BMessage(kMsgEnableScreenSaverBox)); BBox* box = new BBox("EnableScreenSaverBox"); box->SetLabel(fEnableCheckBox); // Start Screensaver BStringView* startScreenSaver = new BStringView("startScreenSaver", B_TRANSLATE("Start screensaver")); startScreenSaver->SetAlignment(B_ALIGN_RIGHT); fRunSlider = new TimeSlider("RunSlider", kMsgRunSliderChanged, kMsgRunSliderUpdate); // Turn Off rgb_color textColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DISABLED_LABEL_TINT); fTurnOffNotSupported = new BTextView("not_supported", be_plain_font, &textColor, B_WILL_DRAW); fTurnOffNotSupported->SetExplicitMinSize(BSize(B_SIZE_UNSET, 3 + textHeight * 3)); fTurnOffNotSupported->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fTurnOffNotSupported->MakeEditable(false); fTurnOffNotSupported->MakeSelectable(false); fTurnOffNotSupported->SetText( B_TRANSLATE("Display Power Management Signaling not available")); fTurnOffCheckBox = new BCheckBox("TurnOffScreenCheckBox", B_TRANSLATE("Turn off screen"), new BMessage(kMsgTurnOffCheckBox)); fTurnOffCheckBox->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER)); fTurnOffSlider = new TimeSlider("TurnOffSlider", kMsgTurnOffSliderChanged, kMsgTurnOffSliderUpdate); // Password fPasswordCheckBox = new BCheckBox("PasswordCheckbox", B_TRANSLATE("Password lock"), new BMessage(kMsgPasswordCheckBox)); fPasswordCheckBox->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER)); fPasswordSlider = new TimeSlider("PasswordSlider", kMsgPasswordSliderChanged, kMsgPasswordSliderUpdate); fPasswordButton = new BButton("PasswordButton", B_TRANSLATE("Password" B_UTF8_ELLIPSIS), new BMessage(kMsgChangePassword)); // Bottom float monitorHeight = 10 + textHeight * 3; float aspectRatio = 4.0f / 3.0f; float monitorWidth = monitorHeight * aspectRatio; BRect monitorRect = BRect(0, 0, monitorWidth, monitorHeight); fFadeNow = new ScreenCornerSelector(monitorRect, "FadeNow", new BMessage(kMsgFadeCornerChanged), B_FOLLOW_NONE); BTextView* fadeNowText = new BTextView("FadeNowText", B_WILL_DRAW); fadeNowText->SetExplicitMinSize(BSize(B_SIZE_UNSET, 4 + textHeight * 4)); fadeNowText->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fadeNowText->MakeEditable(false); fadeNowText->MakeSelectable(false); fadeNowText->SetText(B_TRANSLATE("Fade now when mouse is here")); fFadeNever = new ScreenCornerSelector(monitorRect, "FadeNever", new BMessage(kMsgNeverFadeCornerChanged), B_FOLLOW_NONE); BTextView* fadeNeverText = new BTextView("FadeNeverText", B_WILL_DRAW); fadeNeverText->SetExplicitMinSize(BSize(B_SIZE_UNSET, 4 + textHeight * 4)); fadeNeverText->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fadeNeverText->MakeEditable(false); fadeNeverText->MakeSelectable(false); fadeNeverText->SetText(B_TRANSLATE("Don't fade when mouse is here")); box->AddChild(BLayoutBuilder::Group<>(B_VERTICAL) .SetInsets(B_USE_DEFAULT_SPACING, 0, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) .AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING) .Add(startScreenSaver, 0, 0) .Add(fRunSlider, 1, 0) .Add(fTurnOffCheckBox, 0, 1) .Add(BLayoutBuilder::Group<>(B_VERTICAL) .Add(fTurnOffNotSupported) .Add(fTurnOffSlider) .View(), 1, 1) .Add(fPasswordCheckBox, 0, 2) .Add(fPasswordSlider, 1, 2) .End() .AddGroup(B_HORIZONTAL) .AddGlue() .Add(fPasswordButton) .End() .AddGlue() .AddGroup(B_HORIZONTAL) .Add(fFadeNow) .AddGroup(B_VERTICAL, 0) .Add(fadeNowText) .AddGlue() .End() .Add(fFadeNever) .AddGroup(B_VERTICAL, 0) .Add(fadeNeverText) .AddGlue() .End() .End() .AddGlue() .View()); BLayoutBuilder::Group<>(this, B_HORIZONTAL) .SetInsets(B_USE_SMALL_SPACING) .Add(box) .End(); }
// StartConfig void IFSSaver::StartConfig(BView *view) { BRect bounds = view->Bounds(); bounds.InsetBy(10.0, 10.0); BRect frame(0.0, 0.0, bounds.Width(), 20.0); // the additive check box fAdditiveCB = new BCheckBox(frame, "additive setting", B_TRANSLATE("Render dots additive"), new BMessage(MSG_TOGGLE_ADDITIVE), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); fAdditiveCB->SetValue(fAdditive); fAdditiveCB->ResizeToPreferred(); bounds.bottom -= fAdditiveCB->Bounds().Height() * 2.0; fAdditiveCB->MoveTo(bounds.LeftBottom()); view->AddChild(fAdditiveCB); // the additive check box fSpeedS = new BSlider(frame, "speed setting", B_TRANSLATE("Morphing speed:"), new BMessage(MSG_SET_SPEED), 1, 12, B_BLOCK_THUMB, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM); fSpeedS->SetValue(fSpeed); fSpeedS->SetHashMarks(B_HASH_MARKS_BOTTOM); fSpeedS->SetHashMarkCount(12); fSpeedS->ResizeToPreferred(); bounds.bottom -= fSpeedS->Bounds().Height() + 15.0; fSpeedS->MoveTo(bounds.LeftBottom()); view->AddChild(fSpeedS); // the info text view BRect textRect = bounds; textRect.OffsetTo(0.0, 0.0); BTextView* textView = new BTextView(bounds, B_EMPTY_STRING, textRect, B_FOLLOW_ALL, B_WILL_DRAW); textView->SetViewColor(view->ViewColor()); textView->Insert(B_TRANSLATE("Iterated Function System\n\n" ""B_UTF8_COPYRIGHT" 1997 Massimino Pascal\n\n" "xscreensaver port by Stephan Aßmus\n" "<*****@*****.**>")); textView->SetStylable(true); textView->SetFontAndColor(0, 24, be_bold_font); // textView->SetFontAndColor(25, 255, be_plain_font); textView->MakeEditable(false); view->AddChild(textView); // make sure we receive messages from the views we added if (BWindow* window = view->Window()) window->AddHandler(this); fAdditiveCB->SetTarget(this); fSpeedS->SetTarget(this); }
bool AuthenticationPanel::getAuthentication(const BString& text, const BString& previousUser, const BString& previousPass, bool previousRememberCredentials, bool badPassword, BString& user, BString& pass, bool* rememberCredentials) { // Configure panel and layout controls. rgb_color infoColor = ui_color(B_PANEL_TEXT_COLOR); BRect textBounds(0, 0, 250, 200); BTextView* textView = new BTextView(textBounds, "text", textBounds, be_plain_font, &infoColor, B_FOLLOW_NONE, B_WILL_DRAW | B_SUPPORTS_LAYOUT); textView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); textView->SetText(text.String()); textView->MakeEditable(false); textView->MakeSelectable(false); m_usernameTextControl->SetText(previousUser.String()); m_passwordTextControl->TextView()->HideTyping(true); // Ignore the previous password, if it didn't work. if (!badPassword) m_passwordTextControl->SetText(previousPass.String()); m_hidePasswordCheckBox->SetValue(B_CONTROL_ON); m_rememberCredentialsCheckBox->SetValue(previousRememberCredentials); // create layout SetLayout(new BGroupLayout(B_VERTICAL, 0.0)); float spacing = be_control_look->DefaultItemSpacing(); AddChild(BGroupLayoutBuilder(B_VERTICAL, 0.0) .Add(BGridLayoutBuilder(0, spacing) .Add(textView, 0, 0, 2) .Add(m_usernameTextControl->CreateLabelLayoutItem(), 0, 1) .Add(m_usernameTextControl->CreateTextViewLayoutItem(), 1, 1) .Add(m_passwordTextControl->CreateLabelLayoutItem(), 0, 2) .Add(m_passwordTextControl->CreateTextViewLayoutItem(), 1, 2) .Add(BSpaceLayoutItem::CreateGlue(), 0, 3) .Add(m_hidePasswordCheckBox, 1, 3) .Add(m_rememberCredentialsCheckBox, 0, 4, 2) .SetInsets(spacing, spacing, spacing, spacing) ) .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER)) .Add(BGroupLayoutBuilder(B_HORIZONTAL, spacing) .AddGlue() .Add(m_cancelButton) .Add(m_okButton) .SetInsets(spacing, spacing, spacing, spacing) ) ); float textHeight = textView->LineHeight(0) * textView->CountLines(); textView->SetExplicitMinSize(BSize(B_SIZE_UNSET, textHeight)); SetDefaultButton(m_okButton); if (badPassword && previousUser.Length()) m_passwordTextControl->MakeFocus(true); else m_usernameTextControl->MakeFocus(true); if (m_parentWindowFrame.IsValid()) CenterIn(m_parentWindowFrame); else CenterOnScreen(); // Start AuthenticationPanel window thread Show(); // Let the window jitter, if the previous password was invalid if (badPassword) PostMessage(kMsgJitter); // Block calling thread // Get the originating window, if it exists, to let it redraw itself. BWindow* window = dynamic_cast<BWindow*>(BLooper::LooperForThread(find_thread(NULL))); if (window) { status_t err; for (;;) { do { err = acquire_sem_etc(m_exitSemaphore, 1, B_RELATIVE_TIMEOUT, 10000); // We've (probably) had our time slice taken away from us } while (err == B_INTERRUPTED); if (err != B_TIMED_OUT) { // Semaphore was finally released or nuked. break; } window->UpdateIfNeeded(); } } else { // No window to update, so just hang out until we're done. while (acquire_sem(m_exitSemaphore) == B_INTERRUPTED) { } } // AuthenticationPanel wants to quit. Lock(); user = m_usernameTextControl->Text(); pass = m_passwordTextControl->Text(); if (rememberCredentials) *rememberCredentials = m_rememberCredentialsCheckBox->Value() == B_CONTROL_ON; bool canceled = m_cancelled; Quit(); // AuthenticationPanel object is TOAST here. return !canceled; }
AntialiasingSettingsView::AntialiasingSettingsView(const char* name) : BView(name, 0) { // collect the current system settings if (get_subpixel_antialiasing(&fCurrentSubpixelAntialiasing) != B_OK) fCurrentSubpixelAntialiasing = false; fSavedSubpixelAntialiasing = fCurrentSubpixelAntialiasing; if (get_hinting_mode(&fCurrentHinting) != B_OK) fCurrentHinting = HINTING_MODE_ON; fSavedHinting = fCurrentHinting; if (get_average_weight(&fCurrentAverageWeight) != B_OK) fCurrentAverageWeight = 100; fSavedAverageWeight = fCurrentAverageWeight; // create the controls // antialiasing menu _BuildAntialiasingMenu(); fAntialiasingMenuField = new BMenuField("antialiasing", B_TRANSLATE("Antialiasing type:"), fAntialiasingMenu, NULL); // "average weight" in subpixel filtering fAverageWeightControl = new BSlider("averageWeightControl", B_TRANSLATE("Reduce colored edges filter strength:"), new BMessage(kMsgSetAverageWeight), 0, 255, B_HORIZONTAL); fAverageWeightControl->SetLimitLabels(B_TRANSLATE("Off"), B_TRANSLATE("Strong")); fAverageWeightControl->SetHashMarks(B_HASH_MARKS_BOTTOM); fAverageWeightControl->SetHashMarkCount(255 / 15); fAverageWeightControl->SetEnabled(false); // hinting menu _BuildHintingMenu(); fHintingMenuField = new BMenuField("hinting", B_TRANSLATE("Glyph hinting:"), fHintingMenu, NULL); #ifdef DISABLE_HINTING_CONTROL fHintingMenuField->SetEnabled(false); #endif #ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING // subpixelAntialiasingDisabledLabel BFont infoFont(*be_plain_font); infoFont.SetFace(B_ITALIC_FACE); rgb_color infoColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_4_TINT); // TODO: Replace with layout friendly constructor once available. BRect textBounds = Bounds(); BTextView* subpixelAntialiasingDisabledLabel = new BTextView( textBounds, "unavailable label", textBounds, &infoFont, &infoColor, B_FOLLOW_NONE, B_WILL_DRAW | B_SUPPORTS_LAYOUT); subpixelAntialiasingDisabledLabel->SetText(B_TRANSLATE( "Subpixel based anti-aliasing in combination with glyph hinting is not " "available in this build of Haiku to avoid possible patent issues. To " "enable this feature, you have to build Haiku yourself and enable " "certain options in the libfreetype configuration header.")); subpixelAntialiasingDisabledLabel->SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR)); subpixelAntialiasingDisabledLabel->MakeEditable(false); subpixelAntialiasingDisabledLabel->MakeSelectable(false); #endif // !FT_CONFIG_OPTION_SUBPIXEL_RENDERING SetLayout(new BGroupLayout(B_VERTICAL)); // controls pane AddChild(BGridLayoutBuilder(10, 10) .Add(fHintingMenuField->CreateLabelLayoutItem(), 0, 0) .Add(fHintingMenuField->CreateMenuBarLayoutItem(), 1, 0) .Add(fAntialiasingMenuField->CreateLabelLayoutItem(), 0, 1) .Add(fAntialiasingMenuField->CreateMenuBarLayoutItem(), 1, 1) .Add(fAverageWeightControl, 0, 2, 2) #ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING // hinting+subpixel unavailable info .Add(subpixelAntialiasingDisabledLabel, 0, 3, 2) #else .Add(BSpaceLayoutItem::CreateGlue(), 0, 3, 2) #endif .SetInsets(10, 10, 10, 10) ); _SetCurrentAntialiasing(); _SetCurrentHinting(); _SetCurrentAverageWeight(); }
void PackageView::_InitView() { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); float fontHeight = be_plain_font->Size(); BTextView* packageDescriptionView = new DescriptionTextView( "package description", fontHeight * 13); packageDescriptionView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); packageDescriptionView->SetText(fInfo.GetDescription()); packageDescriptionView->MakeEditable(false); packageDescriptionView->MakeSelectable(false); BScrollView* descriptionScrollView = new BScrollView( "package description scroll view", packageDescriptionView, 0, false, true, B_NO_BORDER); // Install type menu field fInstallTypes = new BPopUpMenu(B_TRANSLATE("none")); BMenuField* installType = new BMenuField("install_type", B_TRANSLATE("Installation type:"), fInstallTypes); // Install type description text view fInstallTypeDescriptionView = new DescriptionTextView( "install type description", fontHeight * 4); fInstallTypeDescriptionView->MakeEditable(false); fInstallTypeDescriptionView->MakeSelectable(false); fInstallTypeDescriptionView->SetInsets(8, 0, 0, 0); // Left inset needs to match BMenuField text offset fInstallTypeDescriptionView->SetText( B_TRANSLATE("No installation type selected")); fInstallTypeDescriptionView->SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR)); BFont font(be_plain_font); font.SetSize(ceilf(font.Size() * 0.85)); fInstallTypeDescriptionView->SetFontAndColor(&font); BScrollView* installTypeScrollView = new BScrollView( "install type description scroll view", fInstallTypeDescriptionView, 0, false, true, B_NO_BORDER); // Destination menu field fDestination = new BPopUpMenu(B_TRANSLATE("none")); fDestField = new BMenuField("install_to", B_TRANSLATE("Install to:"), fDestination); fBeginButton = new BButton("begin_button", B_TRANSLATE("Begin"), new BMessage(P_MSG_INSTALL)); BLayoutItem* typeLabelItem = installType->CreateLabelLayoutItem(); BLayoutItem* typeMenuItem = installType->CreateMenuBarLayoutItem(); BLayoutItem* destFieldLabelItem = fDestField->CreateLabelLayoutItem(); BLayoutItem* destFieldMenuItem = fDestField->CreateMenuBarLayoutItem(); float forcedMinWidth = be_plain_font->StringWidth("XXX") * 5; destFieldMenuItem->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET)); typeMenuItem->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET)); BAlignment labelAlignment(B_ALIGN_RIGHT, B_ALIGN_VERTICAL_UNSET); typeLabelItem->SetExplicitAlignment(labelAlignment); destFieldLabelItem->SetExplicitAlignment(labelAlignment); // Build the layout BLayoutBuilder::Group<>(this, B_VERTICAL) .Add(descriptionScrollView) .AddGrid(B_USE_SMALL_SPACING, B_USE_DEFAULT_SPACING) .Add(typeLabelItem, 0, 0) .Add(typeMenuItem, 1, 0) .Add(installTypeScrollView, 1, 1) .Add(destFieldLabelItem, 0, 2) .Add(destFieldMenuItem, 1, 2) .End() .AddGroup(B_HORIZONTAL) .AddGlue() .Add(fBeginButton) .End() .SetInsets(B_USE_DEFAULT_SPACING) ; fBeginButton->MakeDefault(true); }
/** * @brief Creates child views. */ void BePreferencesDlg::createViews() { BeDialogControlHelper dch(getDialogLayout()); NativeStringLoader* nsl = CoveredCalcApp::GetInstance(); rgb_color viewColor = { 216, 216, 216, 255 }; rgb_color highColor = { 0, 0, 0, 255 }; // dialog title SetTitle(nsl->LoadNativeString(NSID_PREFERENCES_TITLE)); // BaseView BView* baseView = new BView(Bounds(), PREFERENCES_DIALOG_VIEW_BASE_VIEW, B_FOLLOW_ALL_SIDES, B_WILL_DRAW); AddChild(baseView); baseView->SetViewColor(viewColor); // LangBox MBCString itemnameLangBox = ALITERAL("IDC_GROUP_LANGUAGE"); BBox* langBox = new BBox(dch.GetItemRect(itemnameLangBox, ITEMNAME_WINDOW), PREFERENCES_DIALOG_VIEW_LANG_BOX); baseView->AddChild(langBox); langBox->SetLabel(nsl->LoadNativeString(NSID_PREFERENCES_GROUP_LANGUAGE)); // LangPopup langMenu = new BMenu(""); langMenu->SetLabelFromMarked(true); BMenuField* langPopup = new BMenuField(dch.GetItemRect(ALITERAL("IDC_CMB_LANGUAGE"), itemnameLangBox), PREFERENCES_DIALOG_VIEW_LANG_POPUP, nsl->LoadNativeString(NSID_PREFERENCES_LANGUAGE), langMenu); langBox->AddChild(langPopup); langPopup->SetDivider(dch.GetItemPos(true, ALITERAL("IDC_CMB_LANGUAGE.divider"), ALITERAL("IDC_CMB_LANGUAGE.left"))); langPopup->SetAlignment(B_ALIGN_LEFT); uicLanguageListBox.Init(langPopup, ID_NULL); // LangNotice BRect frameRect = dch.GetItemRect(ALITERAL("IDC_STATIC_LANGUAGE_MESSAGE"), itemnameLangBox); BRect textRect = frameRect; textRect.OffsetTo(0, 0); BTextView* langNotice = new BTextView(frameRect, PREFERENCES_DIALOG_VIEW_LANG_NOTICE, textRect, B_FOLLOW_LEFT | B_FOLLOW_TOP); langBox->AddChild(langNotice); const char* text = nsl->LoadNativeString(NSID_PREFERENCES_LANGUAGE_MESSAGE); langNotice->SetText(text); langNotice->SetFontAndColor(0, strlen(text), be_plain_font, B_FONT_ALL, &highColor); langNotice->SetViewColor(viewColor); langNotice->MakeEditable(false); // KeyMappingBox MBCString itemnameKeyMappingBox = ALITERAL("IDC_GROUP_KEYMAP"); BBox* keyMappingBox = new BBox(dch.GetItemRect(itemnameKeyMappingBox, ITEMNAME_WINDOW), PREFERENCES_DIALOG_VIEW_KEYMAPPING_BOX); baseView->AddChild(keyMappingBox); keyMappingBox->SetLabel(nsl->LoadNativeString(NSID_PREFERENCES_GROUP_KEYMAP)); // KeyMappingPopup BMenu* keyMappingMenu = new BMenu(""); keyMappingMenu->SetLabelFromMarked(true); BMenuField* keyMappingPopup = new BMenuField(dch.GetItemRect(ALITERAL("IDC_CMB_KEYMAPPINGS"), itemnameKeyMappingBox), PREFERENCES_DIALOG_VIEW_KEYMAPPING_POPUP, nsl->LoadNativeString(NSID_PREFERENCES_KEYMAP), keyMappingMenu); keyMappingBox->AddChild(keyMappingPopup); keyMappingPopup->SetDivider(dch.GetItemPos(true, ALITERAL("IDC_CMB_KEYMAPPINGS.divider"), ALITERAL("IDC_CMB_KEYMAPPINGS.left"))); keyMappingPopup->SetAlignment(B_ALIGN_LEFT); uicKeyMapListBox.Init(keyMappingPopup, ID_PREF_KEYMAP_SELECTED); // EditKeyMappingButton BButton* editKeymapButton = new BButton(dch.GetItemRect(ALITERAL("IDC_EDIT_KEYMAPPING"), itemnameKeyMappingBox), PREFERENCES_DIALOG_VIEW_EDIT_KEYMAPPING_BUTTON, nsl->LoadNativeString(NSID_PREFERENCES_EDIT_KEYMAP), new BMessage(ID_PREF_EDIT_KEYMAP)); keyMappingBox->AddChild(editKeymapButton); uicEditKeyMapButton.Init(editKeymapButton); // DuplicateKeyMappingButton BButton* dupKeymapButton = new BButton(dch.GetItemRect(ALITERAL("IDC_DUPLICATE_KEYMAPPING"), itemnameKeyMappingBox), PREFERENCES_DIALOG_VIEW_DUPLICATE_KEYMAPPING_BUTTON, nsl->LoadNativeString(NSID_PREFERENCES_DUPLICATE_KEYMAP), new BMessage(ID_PREF_DUPLICATE_KEYMAP)); keyMappingBox->AddChild(dupKeymapButton); uicDuplicateKeyMapButton.Init(dupKeymapButton); // DeleteKeyMappingButton BButton* delKeymapButton = new BButton(dch.GetItemRect(ALITERAL("IDC_DELETE_KEYMAPPING"), itemnameKeyMappingBox), PREFERENCES_DIALOG_VIEW_DELETE_KEYMAPPING_BUTTON, nsl->LoadNativeString(NSID_PREFERENCES_DELETE_KEYMAP), new BMessage(ID_PREF_DELETE_KEYMAP)); keyMappingBox->AddChild(delKeymapButton); uicDeleteKeyMapButton.Init(delKeymapButton); // CancelButton BButton* cancelButton = new BButton(dch.GetItemRect(ALITERAL("IDCANCEL"), ITEMNAME_WINDOW), PREFERENCES_DIALOG_VIEW_CANCEL, nsl->LoadNativeString(NSID_PREFERENCES_CANCEL), new BMessage(ID_DIALOG_CANCEL)); baseView->AddChild(cancelButton); // OKButton BButton* okButton = new BButton(dch.GetItemRect(ALITERAL("IDOK"), ITEMNAME_WINDOW), PREFERENCES_DIALOG_VIEW_OK, nsl->LoadNativeString(NSID_PREFERENCES_OK), new BMessage(ID_DIALOG_OK)); baseView->AddChild(okButton); SetDefaultButton(okButton); }