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(); }
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()); }
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; }