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(); }
KeyRequestView() : BView("KeyRequestView", B_WILL_DRAW), fPassword(NULL) { SetViewUIColor(B_PANEL_BACKGROUND_COLOR); BGroupLayout* rootLayout = new(std::nothrow) BGroupLayout(B_VERTICAL); if (rootLayout == NULL) return; SetLayout(rootLayout); BGridView* controls = new(std::nothrow) BGridView(); if (controls == NULL) return; BGridLayout* layout = controls->GridLayout(); float inset = ceilf(be_plain_font->Size() * 0.7); rootLayout->SetInsets(inset, inset, inset, inset); rootLayout->SetSpacing(inset); layout->SetSpacing(inset, inset); BStringView* label = new(std::nothrow) BStringView("keyringLabel", B_TRANSLATE("Keyring:")); if (label == NULL) return; int32 row = 0; layout->AddView(label, 0, row); fKeyringName = new(std::nothrow) BStringView("keyringName", ""); if (fKeyringName == NULL) return; layout->AddView(fKeyringName, 1, row++); fPassword = new(std::nothrow) BTextControl(B_TRANSLATE("Password:"******"", NULL); if (fPassword == NULL) return; BLayoutItem* layoutItem = fPassword->CreateTextViewLayoutItem(); layoutItem->SetExplicitMinSize(BSize(fPassword->StringWidth( "0123456789012345678901234567890123456789") + inset, B_SIZE_UNSET)); layout->AddItem(fPassword->CreateLabelLayoutItem(), 0, row); layout->AddItem(layoutItem, 1, row++); BGroupView* buttons = new(std::nothrow) BGroupView(B_HORIZONTAL); if (buttons == NULL) return; fCancelButton = new(std::nothrow) BButton(B_TRANSLATE("Cancel"), new BMessage(kMessageCancel)); buttons->GroupLayout()->AddView(fCancelButton); buttons->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue()); fUnlockButton = new(std::nothrow) BButton(B_TRANSLATE("Unlock"), new BMessage(kMessageUnlock)); buttons->GroupLayout()->AddView(fUnlockButton); BTextView* message = new(std::nothrow) BTextView("message"); message->SetText(B_TRANSLATE("An application wants to access the " "keyring below, but it is locked with a passphrase. Please enter " "the passphrase to unlock the keyring.\n" "If you unlock the keyring, it stays unlocked until the system is " "shut down or the keyring is manually locked again.\n" "If you cancel this dialog the keyring will remain locked.")); message->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR); message->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor); message->MakeEditable(false); message->MakeSelectable(false); message->SetWordWrap(true); rootLayout->AddView(message); rootLayout->AddView(controls); rootLayout->AddView(buttons); }
void pawsStdTreeLayout::SetHorizScroll(int _horizScroll) { horizScroll = _horizScroll; SetLayout(); }
void CGuiNumber::SetNumber(int _Number) { /* _ _ _ _ _ __ _ _ / \ /| ) _) |_|_ |_ |_ / (_) (_| \_/ | /_ _) | _) |_) / (_) | */ std::string Number = std::to_string(_Number); for (int IndexOfChar = Number.length(); IndexOfChar < m_MinLength; IndexOfChar++) { Number.insert(0, "0"); } std::string FinalString; for (int IndexOfRow = 0; IndexOfRow < 3; IndexOfRow++) { for (char& Character : Number) { switch (Character) { case '0': { switch (IndexOfRow) { case 0: FinalString += " _ "; break; case 1: FinalString += "/ \\ "; break; case 2: FinalString += "\\_/ "; break; default: break; } break; } case '1': { switch (IndexOfRow) { case 0: FinalString += " "; break; case 1: FinalString += "/| "; break; case 2: FinalString += " | "; break; default: break; } break; } case '2': { switch (IndexOfRow) { case 0: FinalString += "_ "; break; case 1: FinalString += " ) "; break; case 2: FinalString += "/_ "; break; default: break; } break; } case '3': { switch (IndexOfRow) { case 0: FinalString += "_ "; break; case 1: FinalString += "_) "; break; case 2: FinalString += "_) "; break; default: break; } break; } case '4': { switch (IndexOfRow) { case 0: FinalString += " "; break; case 1: FinalString += "|_|_ "; break; case 2: FinalString += " | "; break; default: break; } break; } case '5': { switch (IndexOfRow) { case 0: FinalString += " _ "; break; case 1: FinalString += "|_ "; break; case 2: FinalString += " _) "; break; default: break; } break; } case '6': { switch (IndexOfRow) { case 0: FinalString += " _ "; break; case 1: FinalString += "|_ "; break; case 2: FinalString += "|_) "; break; default: break; } break; } case '7': { switch (IndexOfRow) { case 0: FinalString += "__ "; break; case 1: FinalString += " / "; break; case 2: FinalString += "/ "; break; default: break; } break; } case '8': { switch (IndexOfRow) { case 0: FinalString += " _ "; break; case 1: FinalString += "(_) "; break; case 2: FinalString += "(_) "; break; default: break; } break; } case '9': { switch (IndexOfRow) { case 0: FinalString += " _ "; break; case 1: FinalString += "(_| "; break; case 2: FinalString += " | "; break; default: break; } break; } default: break; } } } SetWidth(FinalString.length() / 3); SetHeight(3); SetLayout(FinalString); }
SettingsWindow::SettingsWindow(BRect frame) : BWindow(frame, "MediaPlayer settings", B_FLOATING_WINDOW_LOOK, B_FLOATING_APP_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE #ifdef __ANTARES__ | B_AUTO_UPDATE_SIZE_LIMITS) #else ) #endif { #ifdef __ANTARES__ BBox* settingsBox = new BBox(B_PLAIN_BORDER, NULL); BGroupLayout* settingsLayout = new BGroupLayout(B_VERTICAL, 5); settingsBox->SetLayout(settingsLayout); BBox* buttonBox = new BBox(B_PLAIN_BORDER, NULL); BGroupLayout* buttonLayout = new BGroupLayout(B_HORIZONTAL, 5); buttonBox->SetLayout(buttonLayout); BStringView* playModeLabel = new BStringView("stringViewPlayMode", "Play mode"); BStringView* viewOptionsLabel = new BStringView("stringViewViewOpions", "View options"); BStringView* bgMoviesModeLabel = new BStringView("stringViewPlayBackg", "Play background clips at"); BAlignment alignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER); playModeLabel->SetExplicitAlignment(alignment); playModeLabel->SetFont(be_bold_font); viewOptionsLabel->SetExplicitAlignment(alignment); viewOptionsLabel->SetFont(be_bold_font); bgMoviesModeLabel->SetExplicitAlignment(alignment); bgMoviesModeLabel->SetFont(be_bold_font); fAutostartCB = new BCheckBox("chkboxAutostart", "Automatically start playing", new BMessage(M_AUTOSTART)); fCloseWindowMoviesCB = new BCheckBox("chkBoxCloseWindowMovies", "Close window when done playing movies", new BMessage(M_CLOSE_WINDOW_MOVIE)); fCloseWindowSoundsCB = new BCheckBox("chkBoxCloseWindowSounds", "Close window when done playing sounds", new BMessage(M_CLOSE_WINDOW_SOUNDS)); fLoopMoviesCB = new BCheckBox("chkBoxLoopMovie", "Loop movies by default", new BMessage(M_LOOP_MOVIE)); fLoopSoundsCB = new BCheckBox("chkBoxLoopSounds", "Loop sounds by default", new BMessage(M_LOOP_SOUND)); fUseOverlaysCB = new BCheckBox("chkBoxUseOverlays", "Use hardware video overlays if available", new BMessage(M_USE_OVERLAYS)); fScaleBilinearCB = new BCheckBox("chkBoxScaleBilinear", "Scale movies smoothly (non-overlay mode)", new BMessage(M_SCALE_BILINEAR)); fFullVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume", "Full volume", new BMessage(M_START_FULL_VOLUME)); fHalfVolumeBGMoviesRB = new BRadioButton("rdbtnhalfvolume", "Low volume", new BMessage(M_START_HALF_VOLUME)); fMutedVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume", "Muted", new BMessage(M_START_MUTE_VOLUME)); fRevertB = new BButton("revert", "Revert", new BMessage(M_SETTINGS_REVERT)); BButton* cancelButton = new BButton("cancel", "Cancel", new BMessage(M_SETTINGS_CANCEL)); BButton* okButton = new BButton("ok", "OK", new BMessage(M_SETTINGS_SAVE)); okButton->MakeDefault(true); // Build the layout SetLayout(new BGroupLayout(B_HORIZONTAL)); AddChild(BGroupLayoutBuilder(B_VERTICAL, 0) .Add(BGroupLayoutBuilder(settingsLayout) .Add(playModeLabel) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 0) .Add(BSpaceLayoutItem::CreateHorizontalStrut(10)) .Add(BGroupLayoutBuilder(B_VERTICAL, 0) .Add(fAutostartCB) .Add(BGridLayoutBuilder(5, 0) .Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 0, 0) .Add(fCloseWindowMoviesCB, 1, 0) .Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 0, 1) .Add(fCloseWindowSoundsCB, 1, 1) ) .Add(fLoopMoviesCB) .Add(fLoopSoundsCB) ) ) .Add(BSpaceLayoutItem::CreateVerticalStrut(5)) .Add(viewOptionsLabel) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 0) .Add(BSpaceLayoutItem::CreateHorizontalStrut(10)) .Add(BGroupLayoutBuilder(B_VERTICAL, 0) .Add(fUseOverlaysCB) .Add(fScaleBilinearCB) ) ) .Add(BSpaceLayoutItem::CreateVerticalStrut(5)) .Add(bgMoviesModeLabel) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 0) .Add(BSpaceLayoutItem::CreateHorizontalStrut(10)) .Add(BGroupLayoutBuilder(B_VERTICAL, 0) .Add(fFullVolumeBGMoviesRB) .Add(fHalfVolumeBGMoviesRB) .Add(fMutedVolumeBGMoviesRB) ) ) .Add(BSpaceLayoutItem::CreateVerticalStrut(5)) .SetInsets(5, 5, 15, 5) ) .Add(BGroupLayoutBuilder(buttonLayout) .Add(fRevertB) .AddGlue() .Add(cancelButton) .Add(okButton) .SetInsets(5, 5, 5, 5) ) ); #else frame = Bounds(); BView* view = new BView(frame,"SettingsView",B_FOLLOW_ALL_SIDES,B_WILL_DRAW); view->SetViewColor(216, 216, 216); BRect btnRect(80.00, frame.bottom - (SPACE + BUTTONHEIGHT), 145.00, frame.bottom-SPACE); fRevertB = new BButton(btnRect, "revert", "Revert", new BMessage(M_SETTINGS_REVERT)); view->AddChild(fRevertB); btnRect.OffsetBy(btnRect.Width() + SPACE, 0); BButton* btn = new BButton(btnRect, "btnCancel", "Cancel", new BMessage(M_SETTINGS_CANCEL)); view->AddChild(btn); btnRect.OffsetBy(btnRect.Width() + SPACE, 0); btn = new BButton(btnRect, "btnOK", "OK", new BMessage(M_SETTINGS_SAVE)); view->AddChild(btn); BRect rectBox(frame.left + SPACE, frame.top + SPACE, frame.right - SPACE, btnRect.top- SPACE); BBox* bbox = new BBox(rectBox, "box1", B_FOLLOW_ALL_SIDES,B_WILL_DRAW | B_NAVIGABLE, B_FANCY_BORDER); bbox->SetLabel("MediaPlayer Settings"); BFont font; font_height fh1; font.GetHeight(&fh1); BString str("Play Mode:"); BRect rect(rectBox.left, rectBox.top + SPACE, rectBox.right - (12*2), rectBox.top + fh1.leading + fh1.ascent + 10); bbox->AddChild(new BStringView(rect, "stringViewPlayMode", str.String())); rect.OffsetBy(0, rect.Height()); bbox->AddChild(fAutostartCB = new BCheckBox(rect, "chkboxAutostart", "Automatically start playing", new BMessage(M_AUTOSTART))); rect.OffsetBy(SPACE, rect.Height() + SPACEING); bbox->AddChild(fCloseWindowMoviesCB = new BCheckBox(rect, "chkBoxCloseWindowMovies", "Close window when done playing movies", new BMessage(M_CLOSE_WINDOW_MOVIE))); rect.OffsetBy(0, rect.Height() + SPACEING); bbox->AddChild(fCloseWindowSoundsCB = new BCheckBox(rect, "chkBoxCloseWindowSounds", "Close window when done playing sounds", new BMessage(M_CLOSE_WINDOW_SOUNDS))); rect.OffsetBy(-SPACE, rect.Height() + SPACEING); bbox->AddChild(fLoopMoviesCB = new BCheckBox(rect, "chkBoxLoopMovie", "Loop movies by default", new BMessage(M_LOOP_MOVIE))); rect.OffsetBy(0, rect.Height() + SPACEING); bbox->AddChild(fLoopSoundsCB = new BCheckBox(rect, "chkBoxLoopSounds", "Loop sounds by default", new BMessage(M_LOOP_SOUND))); rect.OffsetBy(0, rect.Height() + SPACEING); bbox->AddChild(fUseOverlaysCB = new BCheckBox(rect, "chkBoxUseOverlays", "Use hardware video overlays if available", new BMessage(M_USE_OVERLAYS))); rect.OffsetBy(0, rect.Height() + SPACEING); bbox->AddChild(fScaleBilinearCB = new BCheckBox(rect, "chkBoxScaleBilinear", "Scale movies smoothly (non-overlay mode)", new BMessage(M_SCALE_BILINEAR))); rect.OffsetBy(0, rect.Height() + SPACE + SPACEING); bbox->AddChild(new BStringView(rect, "stringViewPlayBackg", "Play backgrounds clips at:")); rect.OffsetBy(SPACE, rect.Height() + SPACEING); fFullVolumeBGMoviesRB = new BRadioButton(rect, "rdbtnfullvolume", "Full Volume", new BMessage(M_START_FULL_VOLUME)); bbox->AddChild(fFullVolumeBGMoviesRB); rect.OffsetBy(0, rect.Height() + SPACEING); fHalfVolumeBGMoviesRB = new BRadioButton(rect, "rdbtnhalfvolume", "Low Volume", new BMessage(M_START_HALF_VOLUME)); bbox->AddChild(fHalfVolumeBGMoviesRB); rect.OffsetBy(0, rect.Height() + SPACEING); fMutedVolumeBGMoviesRB = new BRadioButton(rect, "rdbtnfullvolume", "Muted", new BMessage(M_START_MUTE_VOLUME)); bbox->AddChild(fMutedVolumeBGMoviesRB); view->AddChild(bbox); AddChild(view); #endif // disable currently unsupported features fLoopMoviesCB->SetEnabled(false); fLoopSoundsCB->SetEnabled(false); }
void ApplicationPreview::SetupViews() { dash::ApplicationPreview* app_preview_model = dynamic_cast<dash::ApplicationPreview*>(preview_model_.get()); if (!app_preview_model) { LOG_ERROR(logger) << "Could not derive application preview model from given parameter."; return; } previews::Style& style = dash::previews::Style::Instance(); auto on_mouse_down = [this](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_->OnMouseDown(x, y, button_flags, key_flags); }; nux::HLayout* image_data_layout = new nux::HLayout(); image_data_layout->SetSpaceBetweenChildren(style.GetPanelSplitWidth()); ///////////////////// // Image image_ = new CoverArt(); AddChild(image_.GetPointer()); UpdateCoverArtImage(image_.GetPointer()); ///////////////////// ///////////////////// // App Data Panel full_data_layout_ = new nux::VLayout(); full_data_layout_->SetPadding(style.GetDetailsTopMargin(), 0, style.GetDetailsBottomMargin(), style.GetDetailsLeftMargin()); full_data_layout_->SetSpaceBetweenChildren(16); ///////////////////// // Main App Info nux::HLayout* main_app_info = new nux::HLayout(); main_app_info->SetSpaceBetweenChildren(style.GetSpaceBetweenIconAndDetails()); ///////////////////// // Icon Layout nux::VLayout* icon_layout = new nux::VLayout(); icon_layout->SetSpaceBetweenChildren(3); app_icon_ = new IconTexture(app_preview_model->app_icon.Get().RawPtr() ? g_icon_to_string(app_preview_model->app_icon.Get().RawPtr()) : "", 72); AddChild(app_icon_.GetPointer()); app_icon_->SetMinimumSize(style.GetAppIconAreaWidth(), style.GetAppIconAreaWidth()); app_icon_->SetMaximumSize(style.GetAppIconAreaWidth(), style.GetAppIconAreaWidth()); app_icon_->mouse_click.connect(on_mouse_down); icon_layout->AddView(app_icon_.GetPointer(), 0); if (app_preview_model->rating >= 0) { app_rating_ = new PreviewRatingsWidget(); AddChild(app_rating_.GetPointer()); app_rating_->SetMaximumHeight(style.GetRatingWidgetHeight()); app_rating_->SetMinimumHeight(style.GetRatingWidgetHeight()); app_rating_->SetRating(app_preview_model->rating); app_rating_->SetReviews(app_preview_model->num_ratings); app_rating_->request_close().connect([this]() { preview_container_->request_close.emit(); }); icon_layout->AddView(app_rating_.GetPointer(), 0); } ///////////////////// ///////////////////// // Data nux::VLayout* app_data_layout = new nux::VLayout(); app_data_layout->SetSpaceBetweenChildren(16); title_subtitle_layout_ = new nux::VLayout(); title_subtitle_layout_->SetSpaceBetweenChildren(style.GetSpaceBetweenTitleAndSubtitle()); title_ = new StaticCairoText(preview_model_->title, true, NUX_TRACKER_LOCATION); AddChild(title_.GetPointer()); title_->SetLines(-1); title_->SetFont(style.title_font().c_str()); title_->mouse_click.connect(on_mouse_down); title_subtitle_layout_->AddView(title_.GetPointer(), 1); if (!preview_model_->subtitle.Get().empty()) { subtitle_ = new StaticCairoText(preview_model_->subtitle, true, NUX_TRACKER_LOCATION); AddChild(subtitle_.GetPointer()); subtitle_->SetFont(style.subtitle_size_font().c_str()); subtitle_->SetLines(-1); subtitle_->mouse_click.connect(on_mouse_down); title_subtitle_layout_->AddView(subtitle_.GetPointer(), 1); } nux::VLayout* app_updated_copywrite_layout = new nux::VLayout(); app_updated_copywrite_layout->SetSpaceBetweenChildren(8); if (!app_preview_model->license.Get().empty()) { license_ = new StaticCairoText(app_preview_model->license, true, NUX_TRACKER_LOCATION); AddChild(license_.GetPointer()); license_->SetFont(style.app_license_font().c_str()); license_->SetLines(-1); license_->mouse_click.connect(on_mouse_down); app_updated_copywrite_layout->AddView(license_.GetPointer(), 1); } if (!app_preview_model->last_update.Get().empty()) { std::stringstream last_update; last_update << _("Last Updated") << " " << app_preview_model->last_update.Get(); last_update_ = new StaticCairoText(last_update.str(), true, NUX_TRACKER_LOCATION); AddChild(last_update_.GetPointer()); last_update_->SetFont(style.app_last_update_font().c_str()); last_update_->mouse_click.connect(on_mouse_down); app_updated_copywrite_layout->AddView(last_update_.GetPointer(), 1); } if (!app_preview_model->copyright.Get().empty()) { copywrite_ = new StaticCairoText(app_preview_model->copyright, true, NUX_TRACKER_LOCATION); AddChild(copywrite_.GetPointer()); copywrite_->SetFont(style.app_copywrite_font().c_str()); copywrite_->SetLines(-1); copywrite_->mouse_click.connect(on_mouse_down); app_updated_copywrite_layout->AddView(copywrite_.GetPointer(), 1); } app_data_layout->AddLayout(title_subtitle_layout_); app_data_layout->AddLayout(app_updated_copywrite_layout); // buffer space ///////////////////// main_app_info->AddLayout(icon_layout, 0); main_app_info->AddLayout(app_data_layout, 1); ///////////////////// ///////////////////// // Description nux::ScrollView* app_info = new DetailsScrollView(NUX_TRACKER_LOCATION); app_info->EnableHorizontalScrollBar(false); app_info->mouse_click.connect(on_mouse_down); nux::VLayout* app_info_layout = new nux::VLayout(); app_info_layout->SetSpaceBetweenChildren(12); app_info->SetLayout(app_info_layout); if (!preview_model_->description.Get().empty()) { description_ = new StaticCairoText(preview_model_->description, false, NUX_TRACKER_LOCATION); // not escaped! AddChild(description_.GetPointer()); description_->SetFont(style.description_font().c_str()); description_->SetTextAlignment(StaticCairoText::NUX_ALIGN_TOP); description_->SetLines(-style.GetDescriptionLineCount()); description_->SetLineSpacing(style.GetDescriptionLineSpacing()); description_->mouse_click.connect(on_mouse_down); app_info_layout->AddView(description_.GetPointer()); } if (!preview_model_->GetInfoHints().empty()) { preview_info_hints_ = new PreviewInfoHintWidget(preview_model_, style.GetInfoHintIconSizeWidth()); AddChild(preview_info_hints_.GetPointer()); preview_info_hints_->request_close().connect([this]() { preview_container_->request_close.emit(); }); app_info_layout->AddView(preview_info_hints_.GetPointer()); } ///////////////////// ///////////////////// // Actions action_buttons_.clear(); nux::Layout* actions_layout = BuildGridActionsLayout(preview_model_->GetActions(), action_buttons_); actions_layout->SetLeftAndRightPadding(0, style.GetDetailsRightMargin()); /////////////////// full_data_layout_->AddLayout(main_app_info, 0); full_data_layout_->AddView(app_info, 1); full_data_layout_->AddLayout(actions_layout, 0); ///////////////////// image_data_layout->AddView(image_.GetPointer(), 0); image_data_layout->AddLayout(full_data_layout_, 1); mouse_click.connect(on_mouse_down); SetLayout(image_data_layout); }
GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ): EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ), wxDefaultPosition, wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GERBVIEW_FRAME_NAME ) { m_colorsSettings = &g_ColorsSettings; m_gerberLayout = NULL; m_zoomLevelCoeff = ZOOM_FACTOR( 110 ); // Adjusted to roughly displays zoom level = 1 // when the screen shows a 1:1 image // obviously depends on the monitor, // but this is an acceptable value PAGE_INFO pageInfo( wxT( "GERBER" ) ); SetPageSettings( pageInfo ); m_show_layer_manager_tools = true; m_showAxis = true; // true to show X and Y axis on screen m_showBorderAndTitleBlock = false; // true for reference drawings. m_HotkeysZoomAndGridList = GerbviewHokeysDescr; m_SelLayerBox = NULL; m_DCodeSelector = NULL; m_displayMode = 0; m_drillFileHistory.SetBaseId( ID_GERBVIEW_DRILL_FILE1 ); if( m_canvas ) m_canvas->SetEnableBlockCommands( true ); // Give an icon wxIcon icon; icon.CopyFromBitmap( KiBitmap( icon_gerbview_xpm ) ); SetIcon( icon ); SetLayout( new GBR_LAYOUT() ); SetVisibleLayers( -1 ); // All draw layers visible. SetScreen( new GBR_SCREEN( GetPageSettings().GetSizeIU() ) ); // Create the PCB_LAYER_WIDGET *after* SetLayout(): wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT ); int pointSize = font.GetPointSize(); int screenHeight = wxSystemSettings::GetMetric( wxSYS_SCREEN_Y ); if( screenHeight <= 900 ) pointSize = (pointSize * 8) / 10; m_LayersManager = new GERBER_LAYER_WIDGET( this, m_canvas, pointSize ); // LoadSettings() *after* creating m_LayersManager, because LoadSettings() // initialize parameters in m_LayersManager LoadSettings( config() ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); if( m_LastGridSizeId < 0 ) m_LastGridSizeId = 0; if( m_LastGridSizeId > ID_POPUP_GRID_LEVEL_0_0_1MM-ID_POPUP_GRID_LEVEL_1000 ) m_LastGridSizeId = ID_POPUP_GRID_LEVEL_0_0_1MM-ID_POPUP_GRID_LEVEL_1000; GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); ReCreateMenuBar(); ReCreateHToolbar(); ReCreateOptToolbar(); m_auimgr.SetManagedWindow( this ); EDA_PANEINFO horiz; horiz.HorizontalToolbarPane(); EDA_PANEINFO vert; vert.VerticalToolbarPane(); EDA_PANEINFO mesg; mesg.MessageToolbarPane(); // Create a wxAuiPaneInfo for the Layers Manager, not derived from the template. // the Layers Manager is floatable, but initially docked at far right EDA_PANEINFO lyrs; lyrs.LayersToolbarPane(); lyrs.MinSize( m_LayersManager->GetBestSize() ); lyrs.BestSize( m_LayersManager->GetBestSize() ); lyrs.Caption( _( "Visibles" ) ); lyrs.TopDockable( false ).BottomDockable( false ); if( m_mainToolBar ) m_auimgr.AddPane( m_mainToolBar, wxAuiPaneInfo( horiz ).Name( wxT( "m_mainToolBar" ) ).Top().Row( 0 ) ); if( m_drawToolBar ) m_auimgr.AddPane( m_drawToolBar, wxAuiPaneInfo( vert ).Name( wxT( "m_drawToolBar" ) ).Right().Row( 1 ) ); m_auimgr.AddPane( m_LayersManager, lyrs.Name( wxT( "m_LayersManagerToolBar" ) ).Right().Layer( 0 ) ); if( m_optionsToolBar ) m_auimgr.AddPane( m_optionsToolBar, wxAuiPaneInfo( vert ).Name( wxT( "m_optionsToolBar" ) ).Left() ); if( m_canvas ) m_auimgr.AddPane( m_canvas, wxAuiPaneInfo().Name( wxT( "DrawFrame" ) ).CentrePane() ); if( m_messagePanel ) m_auimgr.AddPane( m_messagePanel, wxAuiPaneInfo( mesg ).Name( wxT( "MsgPanel" ) ).Bottom().Layer( 10 ) ); ReFillLayerWidget(); // this is near end because contents establish size m_LayersManager->ReFillRender(); // Update colors in Render after the config is read m_auimgr.Update(); setActiveLayer( 0, true ); Zoom_Automatique( false ); // Gives a default zoom value }
TeamMonitorWindow::TeamMonitorWindow() : BWindow(BRect(0, 0, 350, 400), B_TRANSLATE("Team monitor"), B_TITLED_WINDOW_LOOK, B_MODAL_ALL_WINDOW_FEEL, B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | B_CLOSE_ON_ESCAPE | B_AUTO_UPDATE_SIZE_LIMITS, B_ALL_WORKSPACES), fQuitting(false), fUpdateRunner(NULL) { BGroupLayout* layout = new BGroupLayout(B_VERTICAL); float inset = 10; layout->SetInsets(inset, inset, inset, inset); layout->SetSpacing(inset); SetLayout(layout); layout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fListView = new BListView("teams"); fListView->SetSelectionMessage(new BMessage(TM_SELECTED_TEAM)); BScrollView* scrollView = new BScrollView("scroll_teams", fListView, 0, B_SUPPORTS_LAYOUT, false, true, B_FANCY_BORDER); layout->AddView(scrollView); BGroupView* groupView = new BGroupView(B_HORIZONTAL); layout->AddView(groupView); fKillButton = new BButton("kill", B_TRANSLATE("Kill application"), new BMessage(TM_KILL_APPLICATION)); groupView->AddChild(fKillButton); fKillButton->SetEnabled(false); fQuitButton = new BButton("quit", B_TRANSLATE("Quit application"), new BMessage(TM_QUIT_APPLICATION)); groupView->AddChild(fQuitButton); fQuitButton->SetEnabled(false); groupView->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue()); fDescriptionView = new TeamDescriptionView; layout->AddView(fDescriptionView); groupView = new BGroupView(B_HORIZONTAL); layout->AddView(groupView); BButton* forceReboot = new BButton("force", B_TRANSLATE("Force reboot"), new BMessage(TM_FORCE_REBOOT)); groupView->GroupLayout()->AddView(forceReboot); BSpaceLayoutItem* glue = BSpaceLayoutItem::CreateGlue(); glue->SetExplicitMinSize(BSize(inset, -1)); groupView->GroupLayout()->AddItem(glue); fRestartButton = new BButton("restart", B_TRANSLATE("Restart the desktop"), new BMessage(TM_RESTART_DESKTOP)); SetDefaultButton(fRestartButton); groupView->GroupLayout()->AddView(fRestartButton); glue = BSpaceLayoutItem::CreateGlue(); glue->SetExplicitMinSize(BSize(inset, -1)); groupView->GroupLayout()->AddItem(glue); fCancelButton = new BButton("cancel", B_TRANSLATE("Cancel"), new BMessage(TM_CANCEL)); SetDefaultButton(fCancelButton); groupView->GroupLayout()->AddView(fCancelButton); BSize preferredSize = layout->View()->PreferredSize(); if (preferredSize.width > Bounds().Width()) ResizeTo(preferredSize.width, Bounds().Height()); if (preferredSize.height > Bounds().Height()) ResizeTo(Bounds().Width(), preferredSize.height); BRect screenFrame = BScreen(this).Frame(); BPoint point; point.x = (screenFrame.Width() - Bounds().Width()) / 2; point.y = (screenFrame.Height() - Bounds().Height()) / 2; if (screenFrame.Contains(point)) MoveTo(point); SetSizeLimits(Bounds().Width(), Bounds().Width() * 2, Bounds().Height(), screenFrame.Height()); fRestartButton->Hide(); AddShortcut('T', B_COMMAND_KEY | B_OPTION_KEY, new BMessage(kMsgLaunchTerminal)); AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); gLocalizedNamePreferred = BLocaleRoster::Default()->IsFilesystemTranslationPreferred(); gTeamMonitorWindow = this; if (be_app->Lock()) { be_app->AddCommonFilter(new BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, B_LOCALE_CHANGED, FilterLocaleChanged)); be_app->Unlock(); } }
void CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset, off_t size) { // Setup the controls fSizeSlider = new SizeSlider("Slider", B_TRANSLATE("Partition size"), NULL, offset, offset + size); fSizeSlider->SetPosition(1.0); fSizeSlider->SetModificationMessage(new BMessage(MSG_SIZE_SLIDER)); fSizeTextControl = new BTextControl("Size Control", "", "", NULL); for(int32 i = 0; i < 256; i++) fSizeTextControl->TextView()->DisallowChar(i); for(int32 i = '0'; i <= '9'; i++) fSizeTextControl->TextView()->AllowChar(i); _UpdateSizeTextControl(); fSizeTextControl->SetModificationMessage( new BMessage(MSG_SIZE_TEXTCONTROL)); fNameTextControl = new BTextControl("Name Control", B_TRANSLATE("Partition name:"), "", NULL); if (!parent->SupportsChildName()) fNameTextControl->SetEnabled(false); fTypePopUpMenu = new BPopUpMenu("Partition Type"); int32 cookie = 0; BString supportedType; while (parent->GetNextSupportedChildType(&cookie, &supportedType) == B_OK) { BMessage* message = new BMessage(MSG_PARTITION_TYPE); message->AddString("type", supportedType); BMenuItem* item = new BMenuItem(supportedType, message); fTypePopUpMenu->AddItem(item); if (strcmp(supportedType, kPartitionTypeBFS) == 0) item->SetMarked(true); } fTypeMenuField = new BMenuField(B_TRANSLATE("Partition type:"), fTypePopUpMenu); const float spacing = be_control_look->DefaultItemSpacing(); BGroupLayout* layout = new BGroupLayout(B_VERTICAL, spacing); layout->SetInsets(spacing, spacing, spacing, spacing); SetLayout(layout); AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing) .Add(fSizeSlider) .Add(fSizeTextControl) .Add(BGridLayoutBuilder(0.0, 5.0) .Add(fNameTextControl->CreateLabelLayoutItem(), 0, 0) .Add(fNameTextControl->CreateTextViewLayoutItem(), 1, 0) .Add(fTypeMenuField->CreateLabelLayoutItem(), 0, 1) .Add(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 1) ) ); status_t err = parent->GetParameterEditor(B_CREATE_PARAMETER_EDITOR, &fEditor); if (err == B_OK && fEditor != NULL) AddChild(fEditor->View()); else fEditor = NULL; BButton* okButton = new BButton(B_TRANSLATE("Create"), new BMessage(MSG_OK)); AddChild(BGroupLayoutBuilder(B_HORIZONTAL, spacing) .AddGlue() .Add(new BButton(B_TRANSLATE("Cancel"), new BMessage(MSG_CANCEL))) .Add(okButton) ); SetDefaultButton(okButton); AddToSubset(fWindow); layout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); }
ModifierKeysWindow::ModifierKeysWindow() : BWindow(BRect(0, 0, 360, 220), B_TRANSLATE("Modifier keys"), B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS) { get_key_map(&fCurrentMap, &fCurrentBuffer); get_key_map(&fSavedMap, &fSavedBuffer); BStringView* keyRole = new BStringView("key role", B_TRANSLATE_COMMENT("Role", "As in the role of a modifier key")); keyRole->SetAlignment(B_ALIGN_RIGHT); keyRole->SetFont(be_bold_font); BStringView* keyLabel = new BStringView("key label", B_TRANSLATE_COMMENT("Key", "As in a computer keyboard key")); keyLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); keyLabel->SetFont(be_bold_font); BMenuField* shiftMenuField = _CreateShiftMenuField(); shiftMenuField->SetAlignment(B_ALIGN_RIGHT); BMenuField* controlMenuField = _CreateControlMenuField(); controlMenuField->SetAlignment(B_ALIGN_RIGHT); BMenuField* optionMenuField = _CreateOptionMenuField(); optionMenuField->SetAlignment(B_ALIGN_RIGHT); BMenuField* commandMenuField = _CreateCommandMenuField(); commandMenuField->SetAlignment(B_ALIGN_RIGHT); fShiftConflictView = new ConflictView("shift warning view"); fShiftConflictView->SetExplicitMaxSize(BSize(15, 15)); fControlConflictView = new ConflictView("control warning view"); fControlConflictView->SetExplicitMaxSize(BSize(15, 15)); fOptionConflictView = new ConflictView("option warning view"); fOptionConflictView->SetExplicitMaxSize(BSize(15, 15)); fCommandConflictView = new ConflictView("command warning view"); fCommandConflictView->SetExplicitMaxSize(BSize(15, 15)); fCancelButton = new BButton("cancelButton", B_TRANSLATE("Cancel"), new BMessage(B_QUIT_REQUESTED)); fRevertButton = new BButton("revertButton", B_TRANSLATE("Revert"), new BMessage(kMsgRevertModifiers)); fRevertButton->SetEnabled(false); fOkButton = new BButton("okButton", B_TRANSLATE("Set modifier keys"), new BMessage(kMsgApplyModifiers)); fOkButton->MakeDefault(true); // Build the layout SetLayout(new BGroupLayout(B_VERTICAL)); float forcedMinWidth = be_plain_font->StringWidth("XXX") * 4; keyRole->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET)); BLayoutItem* shiftLabel = shiftMenuField->CreateLabelLayoutItem(); shiftLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET)); BLayoutItem* controlLabel = controlMenuField->CreateLabelLayoutItem(); controlLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET)); BLayoutItem* optionLabel = optionMenuField->CreateLabelLayoutItem(); optionLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET)); BLayoutItem* commandLabel = commandMenuField->CreateLabelLayoutItem(); commandLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET)); AddChild(BLayoutBuilder::Group<>(B_VERTICAL, B_USE_SMALL_SPACING) .AddGroup(B_HORIZONTAL) .Add(keyRole) .Add(keyLabel) .End() .AddGroup(B_HORIZONTAL) .Add(shiftLabel) .Add(shiftMenuField->CreateMenuBarLayoutItem()) .Add(fShiftConflictView) .End() .AddGroup(B_HORIZONTAL) .Add(controlLabel) .Add(controlMenuField->CreateMenuBarLayoutItem()) .Add(fControlConflictView) .End() .AddGroup(B_HORIZONTAL) .Add(optionLabel) .Add(optionMenuField->CreateMenuBarLayoutItem()) .Add(fOptionConflictView) .End() .AddGroup(B_HORIZONTAL) .Add(commandLabel) .Add(commandMenuField->CreateMenuBarLayoutItem()) .Add(fCommandConflictView) .End() .AddGlue() .AddGroup(B_HORIZONTAL) .Add(fCancelButton) .AddGlue() .Add(fRevertButton) .Add(fOkButton) .End() .SetInsets(B_USE_DEFAULT_SPACING) ); _MarkMenuItems(); _ValidateDuplicateKeys(); PostMessage(kMsgHideShowIcons); }
PageSetupWindow::PageSetupWindow(BMessage *msg, const char *printerName) : BlockingWindow(BRect(0, 0, 100, 100), "Page setup", B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE), fSetupMsg(msg), fPrinterDirName(printerName) { if (printerName) SetTitle(BString(printerName).Append(" Page setup").String()); // load orientation if (fSetupMsg->FindInt32("orientation", &fCurrentOrientation) != B_OK) fCurrentOrientation = PrinterDriver::PORTRAIT_ORIENTATION; // load page rect BRect page; float width = letter_width; float height = letter_height; if (fSetupMsg->FindRect("preview:paper_rect", &page) == B_OK) { width = page.Width(); height = page.Height(); } else { page.Set(0, 0, width, height); } BString label; if (fSetupMsg->FindString("preview:paper_size", &label) != B_OK) label = "Letter"; // Load units int32 units; if (fSetupMsg->FindInt32("units", &units) != B_OK) units = kUnitInch; // re-calculate the margin from the printable rect in points BRect margin = page; if (fSetupMsg->FindRect("preview:printable_rect", &margin) == B_OK) { margin.top -= page.top; margin.left -= page.left; margin.right = page.right - margin.right; margin.bottom = page.bottom - margin.bottom; } else { margin.Set(28.34, 28.34, 28.34, 28.34); // 28.34 dots = 1cm } fMarginView = new MarginView(int32(width), int32(height), margin, MarginUnit(units)); BPopUpMenu* pageSizePopUpMenu = new BPopUpMenu("Page size"); pageSizePopUpMenu->SetRadioMode(true); fPageSizeMenu = new BMenuField("page_size", "Page size:", pageSizePopUpMenu); fPageSizeMenu->Menu()->SetLabelFromMarked(true); for (int32 i = 0; pageFormat[i].label != NULL; i++) { BMessage* message = new BMessage(PAGE_SIZE_CHANGED); message->AddFloat("width", pageFormat[i].width); message->AddFloat("height", pageFormat[i].height); BMenuItem* item = new BMenuItem(pageFormat[i].label, message); pageSizePopUpMenu->AddItem(item); if (label.Compare(pageFormat[i].label) == 0) item->SetMarked(true); } BPopUpMenu* orientationPopUpMenu = new BPopUpMenu("Orientation"); orientationPopUpMenu->SetRadioMode(true); fOrientationMenu = new BMenuField("orientation", "Orientation:", orientationPopUpMenu); fOrientationMenu->Menu()->SetLabelFromMarked(true); for (int32 i = 0; orientation[i].label != NULL; i++) { BMessage* message = new BMessage(ORIENTATION_CHANGED); message->AddInt32("orientation", orientation[i].orientation); BMenuItem* item = new BMenuItem(orientation[i].label, message); orientationPopUpMenu->AddItem(item); if (fCurrentOrientation == orientation[i].orientation) item->SetMarked(true); } float scale0; BString scale; if (fSetupMsg->FindFloat("scale", &scale0) == B_OK) scale << (int)scale0; else scale = "100"; fScaleControl = new BTextControl("scale", "Scale [%]:", scale.String(), NULL); for (uint32 i = 0; i < '0'; i++) fScaleControl->TextView()->DisallowChar(i); for (uint32 i = '9' + 1; i < 255; i++) fScaleControl->TextView()->DisallowChar(i); fScaleControl->TextView()->SetMaxBytes(3); BBox *separator = new BBox("separator"); separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1)); BButton *cancel = new BButton("cancel", "Cancel", new BMessage(CANCEL_MSG)); BButton *ok = new BButton("ok", "OK", new BMessage(OK_MSG)); ok->MakeDefault(true); BGridView* settings = new BGridView(); BGridLayout* settingsLayout = settings->GridLayout(); settingsLayout->AddItem(fPageSizeMenu->CreateLabelLayoutItem(), 0, 0); settingsLayout->AddItem(fPageSizeMenu->CreateMenuBarLayoutItem(), 1, 0); settingsLayout->AddItem(fOrientationMenu->CreateLabelLayoutItem(), 0, 1); settingsLayout->AddItem(fOrientationMenu->CreateMenuBarLayoutItem(), 1, 1); settingsLayout->AddItem(fScaleControl->CreateLabelLayoutItem(), 0, 2); settingsLayout->AddItem(fScaleControl->CreateTextViewLayoutItem(), 1, 2); settingsLayout->SetSpacing(0, 0); SetLayout(new BGroupLayout(B_VERTICAL)); AddChild(BGroupLayoutBuilder(B_VERTICAL, 0) .AddGroup(B_HORIZONTAL, 5, 1) .AddGroup(B_VERTICAL, 0, 1.0f) .Add(fMarginView) .AddGlue() .End() .AddGroup(B_VERTICAL, 0, 1.0f) .Add(settings) .AddGlue() .End() .End() .Add(separator) .AddGroup(B_HORIZONTAL, 10, 1.0f) .AddGlue() .Add(cancel) .Add(ok) .End() .SetInsets(10, 10, 10, 10) ); BRect winFrame(Frame()); BRect screenFrame(BScreen().Frame()); MoveTo((screenFrame.right - winFrame.right) / 2, (screenFrame.bottom - winFrame.bottom) / 2); }
void CFileCommentsPage::OnDrawItem(int /*nIDCtl*/, LPDRAWITEMSTRUCT lpDrawItemStruct) { if ( lpDrawItemStruct->itemID == (UINT)-1 || ( lpDrawItemStruct->itemAction & ODA_SELECT ) == 0 && ( lpDrawItemStruct->itemAction & ODA_DRAWENTIRE ) == 0 ) return; const int nRating = lpDrawItemStruct->itemID; CRect rcItem( &lpDrawItemStruct->rcItem ); CDC dc; dc.Attach( lpDrawItemStruct->hDC ); if ( Settings.General.LanguageRTL ) SetLayout( dc.m_hDC, LAYOUT_RTL ); CFont* pOldFont = (CFont*)dc.SelectObject( nRating > 0 ? &theApp.m_gdiFontBold : &theApp.m_gdiFont ); dc.SetBkMode( TRANSPARENT ); if ( lpDrawItemStruct->itemState & ODS_SELECTED ) { dc.SetTextColor( Colors.m_crHiText ); if ( Images.m_bmSelected.m_hObject ) CoolInterface.DrawWatermark( &dc, &rcItem, &Images.m_bmSelected, FALSE ); // No overdraw else dc.FillSolidRect( &rcItem, Colors.m_crHighlight ); } else // Unselected { dc.SetTextColor( Colors.m_crText ); dc.FillSolidRect( &rcItem, Colors.m_crSysWindow ); } rcItem.DeflateRect( 4, 1 ); if ( nRating > 1 ) { for ( int nStar = nRating - 1; nStar; nStar-- ) { rcItem.right -= 16; CoolInterface.Draw( &dc, IDI_STAR, 16, rcItem.right, rcItem.top, CLR_NONE, ( lpDrawItemStruct->itemState & ODS_SELECTED ) ); rcItem.right -= 2; } } else if ( nRating == 1 ) { rcItem.right -= 16; CoolInterface.Draw( &dc, IDI_FAKE, 16, rcItem.right, rcItem.top, CLR_NONE, ( lpDrawItemStruct->itemState & ODS_SELECTED ) ); } if ( ( lpDrawItemStruct->itemState & ODS_SELECTED ) == 0 && nRating >= 0 && nRating < 7 ) { static COLORREF crRating[7] = { Colors.m_crRatingNull, // Unrated Colors.m_crRating0, // Fake Colors.m_crRating1, // Poor Colors.m_crRating2, // Average Colors.m_crRating3, // Good Colors.m_crRating4, // Very good Colors.m_crRating5, // Excellent }; dc.SetTextColor( crRating[ nRating ] ); } CString str; m_wndRating.GetLBText( nRating, str ); dc.DrawText( str, &rcItem, DT_SINGLELINE|DT_LEFT|DT_VCENTER|DT_NOPREFIX ); dc.SelectObject( pOldFont ); dc.Detach(); }
void HWindow::InitGUI() { fEventList = new HEventList(); fEventList->SetType(BMediaFiles::B_SOUNDS); fEventList->SetSelectionMode(B_SINGLE_SELECTION_LIST); BGroupView* view = new BGroupView(); BBox* box = new BBox("", B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP | B_PULSE_NEEDED); BMenu* menu = new BMenu("file"); menu->SetRadioMode(true); menu->SetLabelFromMarked(true); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("<none>"), new BMessage(M_NONE_MESSAGE))); menu->AddItem(new BMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS), new BMessage(M_OTHER_MESSAGE))); BString label(B_TRANSLATE("Sound file:")); BMenuField* menuField = new BMenuField("filemenu", label, menu); menuField->SetDivider(menuField->StringWidth(label) + 10); BButton* stopbutton = new BButton("stop", B_TRANSLATE("Stop"), new BMessage(M_STOP_MESSAGE)); stopbutton->SetEnabled(false); BButton* playbutton = new BButton("play", B_TRANSLATE("Play"), new BMessage(M_PLAY_MESSAGE)); playbutton->SetEnabled(false); const float kInset = be_control_look->DefaultItemSpacing(); view->SetLayout(new BGroupLayout(B_HORIZONTAL)); view->AddChild(BGroupLayoutBuilder(B_VERTICAL, kInset) .AddGroup(B_HORIZONTAL) .Add(menuField) .AddGlue() .End() .AddGroup(B_HORIZONTAL, kInset) .AddGlue() .Add(playbutton) .Add(stopbutton) .End() .SetInsets(kInset, kInset, kInset, kInset) ); box->AddChild(view); SetLayout(new BGroupLayout(B_HORIZONTAL)); AddChild(BGroupLayoutBuilder(B_VERTICAL) .AddGroup(B_VERTICAL, kInset) .Add(fEventList) .Add(box) .End() .SetInsets(kInset, kInset, kInset, kInset) ); // setup file menu SetupMenuField(); BMenuItem* noneItem = menu->FindItem(B_TRANSLATE("<none>")); if (noneItem != NULL) noneItem->SetMarked(true); }
NCDialog::NCDialog( bool asChild, int nId, NCDialogParent* parent, const unicode_t* headerText, ButtonDataNode* blist ) //, unsigned bcolor, unsigned fcolor) : OperThreadWin( asChild ? Win::WT_CHILD : WT_MAIN /*WT_POPUP*/, 0, nId, parent ), //, &crect(0,0,300,100)), _shadow( parent ), // _fcolor(fcolor), // _bcolor(bcolor), _header( nId, this, headerText ), _lo( 9, 9 ), _buttonLo( 3, 16 ), _headerLo( 3, 3 ), _parentLo( 3, 3 ), enterCmd( 0 ), m_nId( nId ) { Enable(); _lo.SetLineGrowth( 4 ); _lo.SetColGrowth( 4 ); _lo.ColSet( 0, 2 ); _lo.ColSet( 1, 10 ); _lo.ColSet( 2, 3 ); _lo.ColSet( 3, 5 ); _lo.ColSet( 5, 5 ); _lo.ColSet( 6, 3 ); _lo.ColSet( 7, 10 ); _lo.ColSet( 8, 2 ); _lo.LineSet( 0, 2 ); _lo.LineSet( 1, 10 ); _lo.LineSet( 2, 3 ); _lo.LineSet( 3, 3 ); //_lo.LineSet(5, 5); _lo.LineSet( 6, 3 ); _lo.LineSet( 7, 5 ); _lo.LineSet( 8, 2 ); _lo.ColSet( 4, 16, 100000 ); _lo.LineSet( 4, 16, 100000 ); _lo.AddRect( &_borderRect, 0, 0, 8, 8 ); _lo.AddRect( &_frameRect, 2, 2, 6, 6 ); _headerLo.ColSet( 0, 1, 1000 ); _headerLo.ColSet( 2, 1, 1000 ); _headerLo.LineSet( 0, 2 ); _headerLo.LineSet( 2, 2 ); _headerLo.AddWin( &_header, 1, 1 ); _lo.AddLayout( &_headerLo, 1, 4 ); _buttonLo.ColSet( 0, 10, 1000 ); _buttonLo.ColSet( 15, 10, 1000 ); _buttonLo.LineSet( 0, 2 ); _buttonLo.LineSet( 2, 2 ); _parentLo.ColSet( 0, 20, 1000 ); _parentLo.ColSet( 2, 20, 1000 ); _parentLo.LineSet( 0, 20, 1000 ); _parentLo.LineSet( 2, 20, 1000 ); _parentLo.AddWin( this, 1, 1 ); _parentLo.SetLineGrowth( 0 ); _parentLo.SetLineGrowth( 2 ); _parentLo.SetColGrowth( 0 ); _parentLo.SetColGrowth( 2 ); if ( blist ) { int n = 0; int minW = 0; for ( ; blist->utf8text && n < 7; blist++, n++ ) { clPtr<Button> p = new Button( 0, this, utf8_to_unicode( _LT( carray_cat<char>( "DB>", blist->utf8text ).data(), blist->utf8text ) ).data(), blist->cmd ); p->Show(); p->Enable(); if ( n > 0 ) { _buttonLo.ColSet( n * 2, 5 ); } _buttonLo.AddWin( p.ptr(), 1, n * 2 + 1 ); if ( minW < p->GetLSize().x.minimal ) { minW = p->GetLSize().x.minimal; } _bList.append( p ); //break; ??? } if ( minW > 0 ) for ( int i = 0; i < _bList.count(); i++ ) { LSize s = _bList[i]->GetLSize(); s.x.minimal = s.x.maximal = minW; _bList[i]->SetLSize( s ); }; if ( _bList.count() ) { _bList[0]->SetFocus(); } } _lo.AddLayout( &_buttonLo, 5, 4 ); _header.Enable(); _header.Show(); SetLayout( &_lo ); if ( Type() == WT_CHILD && parent ) { parent->AddLayout( &_parentLo ); } SetPosition(); SetName( appName ); }
SettingsView::SettingsView(MouseSettings& settings) : BBox("main_view"), fSettings(settings) { // Add the "Mouse Type" pop up menu fTypeMenu = new BPopUpMenu("unknown"); fTypeMenu->AddItem(new BMenuItem(B_TRANSLATE("1-Button"), new BMessage(kMsgMouseType))); fTypeMenu->AddItem(new BMenuItem(B_TRANSLATE("2-Button"), new BMessage(kMsgMouseType))); fTypeMenu->AddItem(new BMenuItem(B_TRANSLATE("3-Button"), new BMessage(kMsgMouseType))); BMenuField* typeField = new BMenuField(B_TRANSLATE("Mouse type:"), fTypeMenu); typeField->SetAlignment(B_ALIGN_RIGHT); // Create the "Double-click speed slider... fClickSpeedSlider = new BSlider("double_click_speed", B_TRANSLATE("Double-click speed"), new BMessage(kMsgDoubleClickSpeed), 0, 1000, B_HORIZONTAL); fClickSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fClickSpeedSlider->SetHashMarkCount(5); fClickSpeedSlider->SetLimitLabels(B_TRANSLATE("Slow"), B_TRANSLATE("Fast")); // Create the "Mouse Speed" slider... fMouseSpeedSlider = new BSlider("mouse_speed", B_TRANSLATE("Mouse speed"), new BMessage(kMsgMouseSpeed), 0, 1000, B_HORIZONTAL); fMouseSpeedSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fMouseSpeedSlider->SetHashMarkCount(7); fMouseSpeedSlider->SetLimitLabels(B_TRANSLATE("Slow"), B_TRANSLATE("Fast")); // Create the "Mouse Acceleration" slider... fAccelerationSlider = new BSlider("mouse_acceleration", B_TRANSLATE("Mouse acceleration"), new BMessage(kMsgAccelerationFactor), 0, 1000, B_HORIZONTAL); fAccelerationSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fAccelerationSlider->SetHashMarkCount(5); fAccelerationSlider->SetLimitLabels(B_TRANSLATE("Slow"), B_TRANSLATE("Fast")); // Mouse image... fMouseView = new MouseView(fSettings); // Create the "Double-click test area" text box... BTextControl* doubleClickTextControl = new BTextControl(NULL, B_TRANSLATE("Double-click test area"), NULL); doubleClickTextControl->SetAlignment(B_ALIGN_LEFT, B_ALIGN_CENTER); // Add the "Mouse focus mode" pop up menu fFocusMenu = new BPopUpMenu(B_TRANSLATE("Click to focus and raise")); const char *focusLabels[] = {B_TRANSLATE_MARK("Click to focus and raise"), B_TRANSLATE_MARK("Click to focus"), B_TRANSLATE_MARK("Focus follows mouse")}; const mode_mouse focusModes[] = {B_NORMAL_MOUSE, B_CLICK_TO_FOCUS_MOUSE, B_FOCUS_FOLLOWS_MOUSE}; for (int i = 0; i < 3; i++) { BMessage* message = new BMessage(kMsgMouseFocusMode); message->AddInt32("mode", focusModes[i]); fFocusMenu->AddItem(new BMenuItem(B_TRANSLATE_NOCOLLECT(focusLabels[i]), message)); } BMenuField* focusField = new BMenuField(B_TRANSLATE("Focus mode:"), fFocusMenu); focusField->SetAlignment(B_ALIGN_RIGHT); // Add the "Focus follows mouse mode" pop up menu fFocusFollowsMouseMenu = new BPopUpMenu(B_TRANSLATE("Normal")); const char *focusFollowsMouseLabels[] = {B_TRANSLATE_MARK("Normal"), B_TRANSLATE_MARK("Warp"), B_TRANSLATE_MARK("Instant warp")}; const mode_focus_follows_mouse focusFollowsMouseModes[] = {B_NORMAL_FOCUS_FOLLOWS_MOUSE, B_WARP_FOCUS_FOLLOWS_MOUSE, B_INSTANT_WARP_FOCUS_FOLLOWS_MOUSE}; for (int i = 0; i < 3; i++) { BMessage* message = new BMessage(kMsgFollowsMouseMode); message->AddInt32("mode_focus_follows_mouse", focusFollowsMouseModes[i]); fFocusFollowsMouseMenu->AddItem(new BMenuItem( B_TRANSLATE_NOCOLLECT(focusFollowsMouseLabels[i]), message)); } BMenuField* focusFollowsMouseField = new BMenuField( "Focus follows mouse mode:", fFocusFollowsMouseMenu); focusFollowsMouseField->SetAlignment(B_ALIGN_RIGHT); // Add the "Click-through" check box fAcceptFirstClickBox = new BCheckBox(B_TRANSLATE("Accept first click"), new BMessage(kMsgAcceptFirstClick)); // dividers BBox* hdivider = new BBox( BRect(0, 0, 1, 1), B_EMPTY_STRING, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER); hdivider->SetExplicitMaxSize(BSize(1, B_SIZE_UNLIMITED)); BBox* vdivider = new BBox( BRect(0, 0, 1, 1), B_EMPTY_STRING, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER); vdivider->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1)); // Build the layout SetLayout(new BGroupLayout(B_HORIZONTAL)); AddChild(BGroupLayoutBuilder(B_VERTICAL, 10) .AddGroup(B_HORIZONTAL, 10) .AddGroup(B_VERTICAL, 10, 1) .AddGroup(B_HORIZONTAL, 10) .AddGlue() .Add(typeField) .AddGlue() .End() .AddGlue() .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) .AddGlue() .Add(fMouseView) .AddGlue() ) .AddGlue() .Add(doubleClickTextControl) .End() .Add(hdivider) .AddGroup(B_VERTICAL, 5, 3) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 0) .Add(fClickSpeedSlider) ) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 0) .Add(fMouseSpeedSlider) ) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 0) .Add(fAccelerationSlider) ) .End() .End() .Add(vdivider) .AddGroup(B_HORIZONTAL, 10) .Add(focusField) .AddGlue() .AddGroup(B_VERTICAL, 0) .Add(fAcceptFirstClickBox) .End() .End() .SetInsets(5, 5, 5, 5) ); }
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; }
ReplaceWindow::ReplaceWindow(BRect frame, BHandler* _handler, BString* searchString, BString *replaceString, bool caseState, bool wrapState, bool backState) : BWindow(frame, "ReplaceWindow", B_MODAL_WINDOW, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS, B_CURRENT_WORKSPACE) { AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); fSearchString = new BTextControl("", B_TRANSLATE("Find:"), NULL, NULL); fReplaceString = new BTextControl("", B_TRANSLATE("Replace with:"), NULL, NULL); fCaseSensBox = new BCheckBox("", B_TRANSLATE("Case-sensitive"), NULL); fWrapBox = new BCheckBox("", B_TRANSLATE("Wrap-around search"), NULL); fBackSearchBox = new BCheckBox("", B_TRANSLATE("Search backwards"), NULL); fAllWindowsBox = new BCheckBox("", B_TRANSLATE("Replace in all windows"), new BMessage(CHANGE_WINDOW)); fUIchange = false; fReplaceAllButton = new BButton("", B_TRANSLATE("Replace all"), new BMessage(MSG_REPLACE_ALL)); fCancelButton = new BButton("", B_TRANSLATE("Cancel"), new BMessage(B_QUIT_REQUESTED)); fReplaceButton = new BButton("", B_TRANSLATE("Replace"), new BMessage(MSG_REPLACE)); SetLayout(new BGroupLayout(B_HORIZONTAL)); AddChild(BGroupLayoutBuilder(B_VERTICAL, 4) .Add(BGridLayoutBuilder(6, 2) .Add(fSearchString->CreateLabelLayoutItem(), 0, 0) .Add(fSearchString->CreateTextViewLayoutItem(), 1, 0) .Add(fReplaceString->CreateLabelLayoutItem(), 0, 1) .Add(fReplaceString->CreateTextViewLayoutItem(), 1, 1) .Add(fCaseSensBox, 1, 2) .Add(fWrapBox, 1, 3) .Add(fBackSearchBox, 1, 4) .Add(fAllWindowsBox, 1, 5) ) .AddGroup(B_HORIZONTAL, 10) .Add(fReplaceAllButton) .AddGlue() .Add(fCancelButton) .Add(fReplaceButton) .End() .SetInsets(10, 10, 10, 10) ); fReplaceButton->MakeDefault(true); fHandler = _handler; const char* searchtext = searchString->String(); const char* replacetext = replaceString->String(); fSearchString->SetText(searchtext); fReplaceString->SetText(replacetext); fSearchString->MakeFocus(true); fCaseSensBox->SetValue(caseState ? B_CONTROL_ON : B_CONTROL_OFF); fWrapBox->SetValue(wrapState ? B_CONTROL_ON : B_CONTROL_OFF); fBackSearchBox->SetValue(backState ? B_CONTROL_ON : B_CONTROL_OFF); }
FindWindow::FindWindow(BMessenger messenger, const BString& str, bool findSelection, bool matchWord, bool matchCase, bool forwardSearch) : BWindow(kWindowFrame, B_TRANSLATE("Find"), B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE | B_AUTO_UPDATE_SIZE_LIMITS), fFindDlgMessenger(messenger) { SetLayout(new BGroupLayout(B_VERTICAL)); BBox* separator = new BBox("separator"); separator->SetExplicitMinSize(BSize(250.0, B_SIZE_UNSET)); separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1.0)); BRadioButton* useSelection = NULL; const float spacing = be_control_look->DefaultItemSpacing(); AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_SMALL_SPACING) .SetInsets(spacing, spacing, spacing, spacing) .Add(BGridLayoutBuilder(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING) .Add(fTextRadio = new BRadioButton(B_TRANSLATE("Use text:"), new BMessage(TOGGLE_FIND_CONTROL)), 0, 0) .Add(fFindLabel = new BTextControl(NULL, NULL, NULL), 1, 0) .Add(useSelection = new BRadioButton(B_TRANSLATE("Use selection"), new BMessage(TOGGLE_FIND_CONTROL)), 0, 1)) .Add(BSpaceLayoutItem::CreateVerticalStrut(spacing / 4)) .Add(separator) .Add(BSpaceLayoutItem::CreateVerticalStrut(spacing / 4)) .Add(fForwardSearchBox = new BCheckBox(B_TRANSLATE("Search forward"))) .Add(fMatchCaseBox = new BCheckBox(B_TRANSLATE("Match case"))) .Add(fMatchWordBox = new BCheckBox(B_TRANSLATE("Match word"))) .AddGroup(B_HORIZONTAL) .AddGlue() .Add(fFindButton = new BButton(B_TRANSLATE("Find"), new BMessage(MSG_FIND))) .End() .TopView()); fFindLabel->SetDivider(0.0); if (!findSelection) { fFindLabel->SetText(str.String()); fFindLabel->MakeFocus(true); } else { fFindLabel->SetEnabled(false); } if (findSelection) useSelection->SetValue(B_CONTROL_ON); else fTextRadio->SetValue(B_CONTROL_ON); if (forwardSearch) fForwardSearchBox->SetValue(B_CONTROL_ON); if (matchCase) fMatchCaseBox->SetValue(B_CONTROL_ON); if (matchWord) fMatchWordBox->SetValue(B_CONTROL_ON); fFindButton->MakeDefault(true); AddShortcut((uint32)'W', B_COMMAND_KEY, new BMessage(MSG_FIND_HIDE)); }
void CLibraryMetaPanel::Update() { CSingleLock pLock1( &Library.m_pSection, TRUE ); CSingleLock pLock2( &m_pSection, TRUE ); CLibraryListPtr pSel( GetViewSelection() ); m_nSelected = pSel ? static_cast< int >( pSel->GetCount() ) : 0; // Show info for library files only CLibraryFile* pFirst = NULL; if ( m_nSelected ) { const CLibraryListItem& pItem = pSel->GetHead(); if ( pItem.Type == CLibraryListItem::LibraryFile ) pFirst = Library.LookupFile( pItem ); if ( pFirst == NULL ) m_nSelected = 0; } m_nIcon32 = m_nIcon48 = -1; if ( m_nSelected == 1 ) { m_nIndex = pFirst->m_nIndex; m_sName = pFirst->m_sName; m_sPath = pFirst->GetPath(); m_sFolder = pFirst->GetFolder(); m_sSize = Settings.SmartVolume( pFirst->GetSize() ); m_sType = ShellIcons.GetTypeString( m_sName ); m_nIcon32 = ShellIcons.Get( pFirst->GetPath(), 32 ); m_nIcon48 = ShellIcons.Get( pFirst->GetPath(), 48 ); m_nRating = pFirst->m_nRating; } else if ( m_nSelected > 1 ) { CString strFormat; LoadString( strFormat, IDS_LIBPANEL_MULTIPLE_FILES ); m_sName.Format( strFormat, m_nSelected ); QWORD nSize = 0; m_sFolder = pFirst->GetFolder(); m_nIcon32 = ShellIcons.Get( pFirst->GetPath(), 32 ); m_nIcon48 = ShellIcons.Get( pFirst->GetPath(), 48 ); m_nRating = 0; for ( POSITION pos = pSel->GetHeadPosition() ; pos ; ) { CLibraryFile* pFile = Library.LookupFile( pSel->GetNext( pos ) ); if ( pFile == NULL ) continue; nSize += pFile->GetSize() / 1024; if ( pFile->IsAvailable() && pFile->GetFolder().CompareNoCase( m_sFolder ) ) { LoadString( m_sFolder, IDS_LIBPANEL_MULTIPLE_FOLDERS ); } int nIcon = ShellIcons.Get( pFile->GetPath(), 48 ); if ( nIcon != m_nIcon48 ) m_nIcon48 = -1; nIcon = ShellIcons.Get( pFile->GetPath(), 32 ); if ( nIcon != m_nIcon32 ) m_nIcon32 = -1; } m_sSize = Settings.SmartVolume( nSize ); m_sPath.Empty(); m_sType.Empty(); } m_pSchema = NULL; if ( pSel ) { for ( POSITION pos = pSel->GetHeadPosition() ; pos ; ) { const CLibraryListItem& pItem = pSel->GetNext( pos ); if ( pItem.Type != CLibraryListItem::LibraryFile ) continue; CLibraryFile* pFile = Library.LookupFile( pItem ); if ( pFile == NULL ) continue; m_pSchema = pFile->m_pSchema; if ( m_pSchema ) break; } } if ( m_pServiceData ) { m_pMetadata->Setup( m_pServiceData ); } else { m_pMetadata->Setup( m_pSchema ); if ( m_pSchema && pSel ) { for ( POSITION pos = pSel->GetHeadPosition() ; pos ; ) { const CLibraryListItem& pItem = pSel->GetNext( pos ); if ( pItem.Type != CLibraryListItem::LibraryFile ) continue; if ( CLibraryFile* pFile = Library.LookupFile( pItem ) ) { if ( pFile->m_pMetadata != NULL && m_pSchema->Equals( pFile->m_pSchema ) ) { m_pMetadata->Combine( pFile->m_pMetadata ); } } } } } m_pMetadata->CreateLinks(); m_pMetadata->Clean( 4096 ); CClientDC dc( this ); if ( Settings.General.LanguageRTL ) SetLayout( dc.m_hDC, LAYOUT_BITMAPORIENTATIONPRESERVED ); SCROLLINFO pInfo; CRect rc; GetClientRect( &rc ); int nThumbSize = min( max( rc.Height() - 16, 64 ), (int)Settings.Library.ThumbSize ); int nHeight = 54 + m_pMetadata->Layout( &dc, rc.Width() - 24 - nThumbSize ); pInfo.cbSize = sizeof(pInfo); pInfo.fMask = SIF_ALL & ~SIF_TRACKPOS; pInfo.nMin = 0; pInfo.nMax = nHeight; pInfo.nPage = rc.Height(); pInfo.nPos = GetScrollPos( SB_VERT ); pInfo.nPos = max( 0, min( pInfo.nPos, pInfo.nMax - (int)pInfo.nPage + 1 ) ); SetScrollInfo( SB_VERT, &pInfo, TRUE ); if ( m_bForceUpdate || ( m_sThumb != m_sPath ) ) { m_bForceUpdate = FALSE; if ( m_bmThumb.m_hObject ) m_bmThumb.DeleteObject(); if ( ! IsThreadAlive() ) { BeginThread( "CtrlLibraryMetaPanel" ); } } pLock2.Unlock(); pLock1.Unlock(); Invalidate(); }
int CEmoticons::AddEmoticon(LPCTSTR pszText, CImageFile* pImage, CRect* pRect, COLORREF crBack, BOOL bButton) { ASSERT( pImage->m_bLoaded && pImage->m_nComponents == 3 ); // ToDo: Allow alpha? if ( pRect->left < 0 || pRect->left + EMOTICON_SIZE > pImage->m_nWidth ) return -1; if ( pRect->top < 0 || pRect->top > pImage->m_nHeight + EMOTICON_SIZE ) return -1; if ( pRect->right != pRect->left + EMOTICON_SIZE ) return -1; if ( pRect->bottom != pRect->top + EMOTICON_SIZE ) return -1; DWORD nPitch = pImage->m_nWidth * pImage->m_nComponents; while ( nPitch & 3 ) nPitch++; BYTE* pSource = pImage->m_pImage; pSource += pRect->top * nPitch + pRect->left * pImage->m_nComponents; HDC hDCMem1, hDCMem2; if ( HDC hDC = GetDC( NULL ) ) // Get screen DC { hDCMem1 = CreateCompatibleDC( hDC ); // Create memory DC for the source if ( ! hDCMem1 ) { ReleaseDC( NULL, hDC ); return -1; } hDCMem2 = CreateCompatibleDC( hDC ); // Create memory DC for the destination if ( ! hDCMem2 ) { DeleteDC( hDCMem1 ); ReleaseDC( NULL, hDC ); return -1; } CBitmap bmOriginal, bmMoved; CDC* pDC = CDC::FromHandle( hDC ); if ( ! bmOriginal.CreateCompatibleBitmap( pDC, EMOTICON_SIZE, EMOTICON_SIZE ) ) // Source bitmap { ReleaseDC( NULL, hDC ); DeleteDC( hDCMem1 ); DeleteDC( hDCMem2 ); return -1; } if ( ! bmMoved.CreateCompatibleBitmap( pDC, EMOTICON_SIZE, EMOTICON_SIZE ) ) // Destination bitmap { ReleaseDC( NULL, hDC ); DeleteDC( hDCMem1 ); DeleteDC( hDCMem2 ); bmOriginal.DeleteObject(); return -1; } BITMAPINFOHEADER pInfo; pInfo.biSize = sizeof( BITMAPINFOHEADER ); pInfo.biWidth = EMOTICON_SIZE; pInfo.biHeight = EMOTICON_SIZE; pInfo.biPlanes = 1; pInfo.biBitCount = 24; pInfo.biCompression = BI_RGB; pInfo.biSizeImage = EMOTICON_SIZE * EMOTICON_SIZE * 3; for ( int nY = EMOTICON_SIZE - 1 ; nY >= 0 ; nY-- ) { SetDIBits( hDCMem1, bmOriginal, nY, 1, pSource, (BITMAPINFO*)&pInfo, DIB_RGB_COLORS ); pSource += nPitch; } HBITMAP hOld_bm1, hOld_bm2; hOld_bm1 = (HBITMAP)SelectObject( hDCMem1, bmOriginal.m_hObject ); hOld_bm2 = (HBITMAP)SelectObject( hDCMem2, bmMoved.m_hObject ); if ( Settings.General.LanguageRTL ) SetLayout( hDCMem2, LAYOUT_RTL ); StretchBlt( hDCMem2, 0, 0, EMOTICON_SIZE, EMOTICON_SIZE, hDCMem1, 0, 0, EMOTICON_SIZE, EMOTICON_SIZE, SRCCOPY ); SelectObject( hDCMem1, hOld_bm1 ); SelectObject( hDCMem2, hOld_bm2 ); DeleteDC( hDCMem1 ); DeleteDC( hDCMem2 ); ReleaseDC( NULL, hDC ); int nIndex = m_pImage.Add( &bmMoved, crBack ); bmMoved.DeleteObject(); bmOriginal.DeleteObject(); m_pIndex.Add( pszText ); if ( bButton ) m_pButtons.Add( nIndex ); return nIndex; } return -1; }
EthernetSettingsView::EthernetSettingsView() : BView("EthernetSettingsView", 0, NULL), fCurrentSettings(NULL) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fSocket = socket(AF_INET, SOCK_DGRAM, 0); _GatherInterfaces(); // build the GUI BGroupLayout* rootLayout = new BGroupLayout(B_VERTICAL); SetLayout(rootLayout); BGridView* controlsGroup = new BGridView(); BGridLayout* layout = controlsGroup->GridLayout(); // insets float inset = ceilf(be_plain_font->Size() * 0.7); rootLayout->SetInsets(inset, inset, inset, inset); rootLayout->SetSpacing(inset); layout->SetSpacing(inset, inset); BPopUpMenu* deviceMenu = new BPopUpMenu(B_TRANSLATE("<no adapter>")); for (int32 i = 0; i < fInterfaces.CountItems(); i++) { BString& name = *fInterfaces.ItemAt(i); BString label = name; BMessage* info = new BMessage(kMsgInfo); info->AddString("interface", name.String()); BMenuItem* item = new BMenuItem(label.String(), info); deviceMenu->AddItem(item); } BPopUpMenu* modeMenu = new BPopUpMenu("modes"); modeMenu->AddItem(new BMenuItem(B_TRANSLATE("Static"), new BMessage(kMsgStaticMode))); modeMenu->AddItem(new BMenuItem(B_TRANSLATE("DHCP"), new BMessage(kMsgDHCPMode))); modeMenu->AddSeparatorItem(); modeMenu->AddItem(new BMenuItem(B_TRANSLATE("Disabled"), new BMessage(kMsgDisabledMode))); BPopUpMenu* networkMenu = new BPopUpMenu("networks"); fDeviceMenuField = new BMenuField(B_TRANSLATE("Adapter:"), deviceMenu); layout->AddItem(fDeviceMenuField->CreateLabelLayoutItem(), 0, 0); layout->AddItem(fDeviceMenuField->CreateMenuBarLayoutItem(), 1, 0); fNetworkMenuField = new BMenuField(B_TRANSLATE("Network:"), networkMenu); layout->AddItem(fNetworkMenuField->CreateLabelLayoutItem(), 0, 1); layout->AddItem(fNetworkMenuField->CreateMenuBarLayoutItem(), 1, 1); fTypeMenuField = new BMenuField(B_TRANSLATE("Mode:"), modeMenu); layout->AddItem(fTypeMenuField->CreateLabelLayoutItem(), 0, 2); layout->AddItem(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 2); fIPTextControl = new BTextControl(B_TRANSLATE("IP address:"), "", NULL); SetupTextControl(fIPTextControl); BLayoutItem* layoutItem = fIPTextControl->CreateTextViewLayoutItem(); layoutItem->SetExplicitMinSize(BSize( fIPTextControl->StringWidth("XXX.XXX.XXX.XXX") + inset, B_SIZE_UNSET)); layout->AddItem(fIPTextControl->CreateLabelLayoutItem(), 0, 3); layout->AddItem(layoutItem, 1, 3); fNetMaskTextControl = new BTextControl(B_TRANSLATE("Netmask:"), "", NULL); SetupTextControl(fNetMaskTextControl); layout->AddItem(fNetMaskTextControl->CreateLabelLayoutItem(), 0, 4); layout->AddItem(fNetMaskTextControl->CreateTextViewLayoutItem(), 1, 4); fGatewayTextControl = new BTextControl(B_TRANSLATE("Gateway:"), "", NULL); SetupTextControl(fGatewayTextControl); layout->AddItem(fGatewayTextControl->CreateLabelLayoutItem(), 0, 5); layout->AddItem(fGatewayTextControl->CreateTextViewLayoutItem(), 1, 5); // TODO: Replace the DNS text controls by a BListView with add/remove // functionality and so on... fPrimaryDNSTextControl = new BTextControl(B_TRANSLATE("DNS #1:"), "", NULL); SetupTextControl(fPrimaryDNSTextControl); layout->AddItem(fPrimaryDNSTextControl->CreateLabelLayoutItem(), 0, 6); layout->AddItem(fPrimaryDNSTextControl->CreateTextViewLayoutItem(), 1, 6); fSecondaryDNSTextControl = new BTextControl(B_TRANSLATE("DNS #2:"), "", NULL); SetupTextControl(fSecondaryDNSTextControl); layout->AddItem(fSecondaryDNSTextControl->CreateLabelLayoutItem(), 0, 7); layout->AddItem(fSecondaryDNSTextControl->CreateTextViewLayoutItem(), 1, 7); fDomainTextControl = new BTextControl(B_TRANSLATE("Domain:"), "", NULL); SetupTextControl(fDomainTextControl); layout->AddItem(fDomainTextControl->CreateLabelLayoutItem(), 0, 8); layout->AddItem(fDomainTextControl->CreateTextViewLayoutItem(), 1, 8); fErrorMessage = new BStringView("error", ""); fErrorMessage->SetAlignment(B_ALIGN_LEFT); fErrorMessage->SetFont(be_bold_font); fErrorMessage->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); layout->AddView(fErrorMessage, 1, 9); // button group (TODO: move to window, but take care of // enabling/disabling) BGroupView* buttonGroup = new BGroupView(B_HORIZONTAL); fRevertButton = new BButton(B_TRANSLATE("Revert"), new BMessage(kMsgRevert)); fRevertButton->SetEnabled(false); buttonGroup->GroupLayout()->AddView(fRevertButton); buttonGroup->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue()); fApplyButton = new BButton(B_TRANSLATE("Apply"), new BMessage(kMsgApply)); fApplyButton->SetEnabled(false); buttonGroup->GroupLayout()->AddView(fApplyButton); rootLayout->AddView(controlsGroup); rootLayout->AddView(buttonGroup); }
ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entry) : BWindow(BRect(0.0f, 0.0f, 250.0f, 340.0f).OffsetBySelf(position), B_TRANSLATE("Application type"), B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | B_FRAME_EVENTS | B_AUTO_UPDATE_SIZE_LIMITS), fChangedProperties(0) { float padding = be_control_look->DefaultItemSpacing(); BAlignment labelAlignment = be_control_look->DefaultLabelAlignment(); BMenuBar* menuBar = new BMenuBar((char*)NULL); menuBar->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP)); BMenu* menu = new BMenu(B_TRANSLATE("File")); fSaveMenuItem = new BMenuItem(B_TRANSLATE("Save"), new BMessage(kMsgSave), 'S'); fSaveMenuItem->SetEnabled(false); menu->AddItem(fSaveMenuItem); BMenuItem* item; menu->AddItem(item = new BMenuItem( B_TRANSLATE("Save into resource file" B_UTF8_ELLIPSIS), NULL)); item->SetEnabled(false); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Close"), new BMessage(B_QUIT_REQUESTED), 'W', B_COMMAND_KEY)); menuBar->AddItem(menu); // Signature fSignatureControl = new BTextControl(B_TRANSLATE("Signature:"), NULL, new BMessage(kMsgSignatureChanged)); fSignatureControl->SetModificationMessage( new BMessage(kMsgSignatureChanged)); // filter out invalid characters that can't be part of a MIME type name BTextView* textView = fSignatureControl->TextView(); textView->SetMaxBytes(B_MIME_TYPE_LENGTH); const char* disallowedCharacters = "<>@,;:\"()[]?="; for (int32 i = 0; disallowedCharacters[i]; i++) { textView->DisallowChar(disallowedCharacters[i]); } // "Application Flags" group BBox* flagsBox = new BBox("flagsBox"); fFlagsCheckBox = new BCheckBox("flags", B_TRANSLATE("Application flags"), new BMessage(kMsgToggleAppFlags)); fFlagsCheckBox->SetValue(B_CONTROL_ON); fSingleLaunchButton = new BRadioButton("single", B_TRANSLATE("Single launch"), new BMessage(kMsgAppFlagsChanged)); fMultipleLaunchButton = new BRadioButton("multiple", B_TRANSLATE("Multiple launch"), new BMessage(kMsgAppFlagsChanged)); fExclusiveLaunchButton = new BRadioButton("exclusive", B_TRANSLATE("Exclusive launch"), new BMessage(kMsgAppFlagsChanged)); fArgsOnlyCheckBox = new BCheckBox("args only", B_TRANSLATE("Args only"), new BMessage(kMsgAppFlagsChanged)); fBackgroundAppCheckBox = new BCheckBox("background", B_TRANSLATE("Background app"), new BMessage(kMsgAppFlagsChanged)); flagsBox->AddChild(BGridLayoutBuilder() .Add(fSingleLaunchButton, 0, 0).Add(fArgsOnlyCheckBox, 1, 0) .Add(fMultipleLaunchButton, 0, 1).Add(fBackgroundAppCheckBox, 1, 1) .Add(fExclusiveLaunchButton, 0, 2) .SetInsets(padding, padding, padding, padding)); flagsBox->SetLabel(fFlagsCheckBox); // "Icon" group BBox* iconBox = new BBox("IconBox"); iconBox->SetLabel(B_TRANSLATE("Icon")); fIconView = new IconView("icon"); fIconView->SetModificationMessage(new BMessage(kMsgIconChanged)); iconBox->AddChild(BGroupLayoutBuilder(B_HORIZONTAL) .Add(fIconView) .SetInsets(padding, padding, padding, padding)); // "Supported Types" group BBox* typeBox = new BBox("typesBox"); typeBox->SetLabel(B_TRANSLATE("Supported types")); fTypeListView = new SupportedTypeListView("Suppported Types", B_SINGLE_SELECTION_LIST); fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected)); BScrollView* scrollView = new BScrollView("type scrollview", fTypeListView, B_FRAME_EVENTS | B_WILL_DRAW, false, true); fAddTypeButton = new BButton("add type", B_TRANSLATE("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddType)); fRemoveTypeButton = new BButton("remove type", B_TRANSLATE("Remove"), new BMessage(kMsgRemoveType)); fTypeIconView = new IconView("type icon"); BView* iconHolder = BGroupLayoutBuilder(B_HORIZONTAL).Add(fTypeIconView); fTypeIconView->SetModificationMessage(new BMessage(kMsgTypeIconsChanged)); typeBox->AddChild(BGridLayoutBuilder(padding, padding) .Add(scrollView, 0, 0, 1, 4) .Add(fAddTypeButton, 1, 0, 1, 2) .Add(fRemoveTypeButton, 1, 2, 1, 2) .Add(iconHolder, 2, 1, 1, 2) .SetInsets(padding, padding, padding, padding) .SetColumnWeight(0, 3) .SetColumnWeight(1, 2) .SetColumnWeight(2, 1)); iconHolder->SetExplicitAlignment( BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE)); // "Version Info" group BBox* versionBox = new BBox("versionBox"); versionBox->SetLabel(B_TRANSLATE("Version info")); fMajorVersionControl = new BTextControl(B_TRANSLATE("Version:"), NULL, NULL); _MakeNumberTextControl(fMajorVersionControl); fMiddleVersionControl = new BTextControl(".", NULL, NULL); _MakeNumberTextControl(fMiddleVersionControl); fMinorVersionControl = new BTextControl(".", NULL, NULL); _MakeNumberTextControl(fMinorVersionControl); fVarietyMenu = new BPopUpMenu("variety", true, true); fVarietyMenu->AddItem(new BMenuItem(B_TRANSLATE("Development"), NULL)); fVarietyMenu->AddItem(new BMenuItem(B_TRANSLATE("Alpha"), NULL)); fVarietyMenu->AddItem(new BMenuItem(B_TRANSLATE("Beta"), NULL)); fVarietyMenu->AddItem(new BMenuItem(B_TRANSLATE("Gamma"), NULL)); item = new BMenuItem(B_TRANSLATE("Golden master"), NULL); fVarietyMenu->AddItem(item); item->SetMarked(true); fVarietyMenu->AddItem(new BMenuItem(B_TRANSLATE("Final"), NULL)); BMenuField* varietyField = new BMenuField("", fVarietyMenu); fInternalVersionControl = new BTextControl("/", NULL, NULL); fShortDescriptionControl = new BTextControl(B_TRANSLATE("Short description:"), NULL, NULL); // TODO: workaround for a GCC 4.1.0 bug? Or is that really what the standard says? version_info versionInfo; fShortDescriptionControl->TextView()->SetMaxBytes( sizeof(versionInfo.short_info)); BStringView* longLabel = new BStringView(NULL, B_TRANSLATE("Long description:")); longLabel->SetExplicitAlignment(labelAlignment); fLongDescriptionView = new TabFilteringTextView("long desc"); fLongDescriptionView->SetMaxBytes(sizeof(versionInfo.long_info)); scrollView = new BScrollView("desc scrollview", fLongDescriptionView, B_FRAME_EVENTS | B_WILL_DRAW, false, true); // TODO: remove workaround (bug #5678) BSize minScrollSize = scrollView->ScrollBar(B_VERTICAL)->MinSize(); minScrollSize.width += fLongDescriptionView->MinSize().width; scrollView->SetExplicitMinSize(minScrollSize); versionBox->AddChild(BGridLayoutBuilder(padding / 2, padding) .Add(fMajorVersionControl->CreateLabelLayoutItem(), 0, 0) .Add(fMajorVersionControl->CreateTextViewLayoutItem(), 1, 0) .Add(fMiddleVersionControl, 2, 0, 2) .Add(fMinorVersionControl, 4, 0, 2) .Add(varietyField, 6, 0, 3) .Add(fInternalVersionControl, 9, 0, 2) .Add(fShortDescriptionControl->CreateLabelLayoutItem(), 0, 1) .Add(fShortDescriptionControl->CreateTextViewLayoutItem(), 1, 1, 10) .Add(longLabel, 0, 2) .Add(scrollView, 1, 2, 10, 3) .SetInsets(padding, padding, padding, padding) .SetRowWeight(3, 3)); // put it all together SetLayout(new BGroupLayout(B_VERTICAL)); AddChild(menuBar); AddChild(BGroupLayoutBuilder(B_VERTICAL, padding) .Add(fSignatureControl) .Add(BGroupLayoutBuilder(B_HORIZONTAL, padding) .Add(flagsBox, 3) .Add(iconBox, 1)) .Add(typeBox) .Add(versionBox) .SetInsets(padding, padding, padding, padding)); SetKeyMenuBar(menuBar); fSignatureControl->MakeFocus(true); BMimeType::StartWatching(this); _SetTo(entry); }
// ------------------------------------------------------ // GLifeConfig Class Constructor Definition GLifeConfig::GLifeConfig(BRect frame, GLifeState* pglsState) : BView(frame, "", B_FOLLOW_ALL_SIDES, B_WILL_DRAW), m_pglsState(pglsState) { SetLayout(new BGroupLayout(B_HORIZONTAL)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); // Info text BStringView* name = new BStringView(frame, B_EMPTY_STRING, B_TRANSLATE("OpenGL \"Game of Life\""), B_FOLLOW_LEFT); BStringView* author = new BStringView(frame, B_EMPTY_STRING, B_TRANSLATE("by Aaron Hill"), B_FOLLOW_LEFT); // Sliders fGridDelay = new BSlider(frame, "GridDelay", B_TRANSLATE("Grid Life Delay: "), new BMessage(kGridDelay), 0, 4, B_BLOCK_THUMB); fGridDelay->SetHashMarks(B_HASH_MARKS_BOTTOM); fGridDelay->SetLimitLabels(B_TRANSLATE("None"), B_TRANSLATE_COMMENT("4x", "This is a factor: the x represents 'times'")); fGridDelay->SetValue(pglsState->GridDelay()); fGridDelay->SetHashMarkCount(5); fGridBorder = new BSlider(frame, "GridBorder", B_TRANSLATE("Grid Border: "), new BMessage(kGridBorder), 0, 10, B_BLOCK_THUMB); fGridBorder->SetHashMarks(B_HASH_MARKS_BOTTOM); fGridBorder->SetLimitLabels("0", "10"); fGridBorder->SetValue(pglsState->GridBorder()); fGridBorder->SetHashMarkCount(11); fGridWidth = new BSlider(frame, "GridWidth", B_TRANSLATE("Grid Width: "), new BMessage(kGridWidth), 10, 100, B_BLOCK_THUMB); fGridWidth->SetHashMarks(B_HASH_MARKS_BOTTOM); //fGridWidth->SetLimitLabels("10", "100"); fGridWidth->SetValue(pglsState->GridWidth()); fGridWidth->SetHashMarkCount(10); fGridHeight = new BSlider(frame, "GridHeight", B_TRANSLATE("Grid Height: "), new BMessage(kGridHeight), 10, 100, B_BLOCK_THUMB); fGridHeight->SetHashMarks(B_HASH_MARKS_BOTTOM); //fGridHeight->SetLimitLabels("10", "100"); fGridHeight->SetValue(pglsState->GridHeight()); fGridHeight->SetHashMarkCount(10); AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_DEFAULT_SPACING) .Add(BGroupLayoutBuilder(B_VERTICAL, 0) .Add(name) .Add(author) ) .AddGlue() .Add(fGridDelay) .Add(fGridBorder) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 0) .Add(fGridWidth) .Add(fGridHeight) ) .SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING) ); // Do our first label update _UpdateLabels(); }
KeymapWindow::KeymapWindow() : BWindow(BRect(80, 50, 880, 380), TR("Keymap"), B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS) { SetLayout(new BGroupLayout(B_VERTICAL)); fKeyboardLayoutView = new KeyboardLayoutView("layout"); fKeyboardLayoutView->SetKeymap(&fCurrentMap); fTextControl = new BTextControl(TR("Sample and clipboard:"), "", NULL); fSwitchShortcutsButton = new BButton("switch", "", new BMessage(kMsgSwitchShortcuts)); fRevertButton = new BButton("revertButton", TR("Revert"), new BMessage(kMsgRevertKeymap)); // controls pane AddChild(BGroupLayoutBuilder(B_VERTICAL) .Add(_CreateMenu()) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) .Add(_CreateMapLists(), 0.25) .Add(BGroupLayoutBuilder(B_VERTICAL, 10) .Add(fKeyboardLayoutView) //.Add(new BStringView("text label", "Sample and clipboard:")) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) .Add(_CreateDeadKeyMenuField(), 0.0) .AddGlue() .Add(fSwitchShortcutsButton)) .Add(fTextControl) .AddGlue(0.0) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) .AddGlue(0.0) .Add(fRevertButton))) .SetInsets(10, 10, 10, 10))); fKeyboardLayoutView->SetTarget(fTextControl->TextView()); fTextControl->MakeFocus(); // Make sure the user keymap directory exists BPath path; find_directory(B_USER_SETTINGS_DIRECTORY, &path); path.Append("Keymap"); entry_ref ref; get_ref_for_path(path.Path(), &ref); BDirectory userKeymapsDir(&ref); if (userKeymapsDir.InitCheck() != B_OK) create_directory(path.Path(), S_IRWXU | S_IRWXG | S_IRWXO); BMessenger messenger(this); fOpenPanel = new BFilePanel(B_OPEN_PANEL, &messenger, &ref, B_FILE_NODE, false, NULL); fSavePanel = new BFilePanel(B_SAVE_PANEL, &messenger, &ref, B_FILE_NODE, false, NULL); BRect windowFrame; BString keyboardLayout; _LoadSettings(windowFrame, keyboardLayout); _SetKeyboardLayout(keyboardLayout.String()); ResizeTo(windowFrame.Width(), windowFrame.Height()); MoveTo(windowFrame.LeftTop()); // TODO: this might be a bug in the interface kit, but scrolling to // selection does not correctly work unless the window is shown. Show(); Lock(); // Try and find the current map name in the two list views (if the name // was read at all) _SelectCurrentMap(); KeymapListItem* current = static_cast<KeymapListItem*>(fUserListView->FirstItem()); fCurrentMap.Load(current->EntryRef()); fPreviousMap = fCurrentMap; fAppliedMap = fCurrentMap; fCurrentMap.SetTarget(this, new BMessage(kMsgKeymapUpdated)); _UpdateButtons(); _UpdateDeadKeyMenu(); _UpdateSwitchShortcutButton(); Unlock(); }
void CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset, off_t size) { // Setup the controls fSizeSlider = new SizeSlider("Slider", TR("Partition size"), NULL, offset, offset + size); fSizeSlider->SetPosition(1.0); fNameTextControl = new BTextControl("Name Control", TR("Partition name:"), "", NULL); if (!parent->SupportsChildName()) fNameTextControl->SetEnabled(false); fTypePopUpMenu = new BPopUpMenu("Partition Type"); int32 cookie = 0; BString supportedType; while (parent->GetNextSupportedChildType(&cookie, &supportedType) == B_OK) { BMessage* message = new BMessage(MSG_PARTITION_TYPE); message->AddString("type", supportedType); BMenuItem* item = new BMenuItem(supportedType, message); fTypePopUpMenu->AddItem(item); if (strcmp(supportedType, kPartitionTypeBFS) == 0) item->SetMarked(true); } fTypeMenuField = new BMenuField(TR("Partition type:"), fTypePopUpMenu, NULL); const float spacing = be_control_look->DefaultItemSpacing(); BGroupLayout* layout = new BGroupLayout(B_VERTICAL, spacing); layout->SetInsets(spacing, spacing, spacing, spacing); SetLayout(layout); AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing) .Add(fSizeSlider) .Add(BGridLayoutBuilder(0.0, 5.0) .Add(fNameTextControl->CreateLabelLayoutItem(), 0, 0) .Add(fNameTextControl->CreateTextViewLayoutItem(), 1, 0) .Add(fTypeMenuField->CreateLabelLayoutItem(), 0, 1) .Add(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 1) ) ); parent->GetChildCreationParameterEditor(NULL, &fEditor); if (fEditor) AddChild(fEditor->View()); BButton* okButton = new BButton(TR("Create"), new BMessage(MSG_OK)); AddChild(BGroupLayoutBuilder(B_HORIZONTAL, spacing) .AddGlue() .Add(new BButton(TR("Cancel"), new BMessage(MSG_CANCEL))) .Add(okButton) ); SetDefaultButton(okButton); AddToSubset(fWindow); layout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); }
CharacterWindow::CharacterWindow() : BWindow(BRect(100, 100, 700, 550), "CharacterMap", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS) { BMessage settings; _LoadSettings(settings); BRect frame; if (settings.FindRect("window frame", &frame) == B_OK) { MoveTo(frame.LeftTop()); ResizeTo(frame.Width(), frame.Height()); } // create GUI SetLayout(new BGroupLayout(B_VERTICAL)); BMenuBar* menuBar = new BMenuBar("menu"); fFilterControl = new BTextControl("Filter:", NULL, NULL); fFilterControl->SetModificationMessage(new BMessage(kMsgFilterChanged)); BButton* clearButton = new BButton("clear", "Clear", new BMessage(kMsgClearFilter)); fUnicodeBlockView = new UnicodeBlockView("unicodeBlocks"); fUnicodeBlockView->SetSelectionMessage( new BMessage(kMsgUnicodeBlockSelected)); BScrollView* unicodeScroller = new BScrollView("unicodeScroller", fUnicodeBlockView, 0, false, true); fCharacterView = new CharacterView("characters"); fCharacterView->SetTarget(this, kMsgCharacterChanged); // TODO: have a context object shared by CharacterView/UnicodeBlockView bool show; if (settings.FindBool("show private blocks", &show) == B_OK) { fCharacterView->ShowPrivateBlocks(show); fUnicodeBlockView->ShowPrivateBlocks(show); } if (settings.FindBool("show contained blocks only", &show) == B_OK) { fCharacterView->ShowContainedBlocksOnly(show); fUnicodeBlockView->ShowPrivateBlocks(show); } const char* family; const char* style; if (settings.FindString("font family", &family) == B_OK && settings.FindString("font style", &style) == B_OK) { _SetFont(family, style); } int32 fontSize; if (settings.FindInt32("font size", &fontSize) == B_OK) { BFont font = fCharacterView->CharacterFont(); if (fontSize < kMinFontSize) fontSize = kMinFontSize; else if (fontSize > kMaxFontSize) fontSize = kMaxFontSize; font.SetSize(fontSize); fCharacterView->SetCharacterFont(font); } else fontSize = (int32)fCharacterView->CharacterFont().Size(); BScrollView* characterScroller = new BScrollView("characterScroller", fCharacterView, 0, false, true); fFontSizeSlider = new FontSizeSlider("fontSizeSlider", "Font size:", new BMessage(kMsgFontSizeChanged), kMinFontSize, kMaxFontSize); fFontSizeSlider->SetValue(fontSize); fCodeView = new BStringView("code", "-"); fCodeView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, fCodeView->PreferredSize().Height())); AddChild(BGroupLayoutBuilder(B_VERTICAL) .Add(menuBar) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)//BSplitLayoutBuilder() .Add(BGroupLayoutBuilder(B_VERTICAL, 10) .Add(BGroupLayoutBuilder(B_HORIZONTAL, 10) .Add(fFilterControl) .Add(clearButton)) .Add(unicodeScroller)) .Add(BGroupLayoutBuilder(B_VERTICAL, 10) .Add(characterScroller) .Add(fFontSizeSlider) .Add(fCodeView)) .SetInsets(10, 10, 10, 10))); // Add menu // "File" menu BMenu* menu = new BMenu("File"); BMenuItem* item; menu->AddItem(item = new BMenuItem("About CharacterMap" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED))); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q')); menu->SetTargetForItems(this); item->SetTarget(be_app); menuBar->AddItem(menu); menu = new BMenu("View"); menu->AddItem(item = new BMenuItem("Show private blocks", new BMessage(kMsgPrivateBlocks))); item->SetMarked(fCharacterView->IsShowingPrivateBlocks()); // TODO: this feature is not yet supported by Haiku! #if 0 menu->AddItem(item = new BMenuItem("Only show blocks contained in font", new BMessage(kMsgContainedBlocks))); item->SetMarked(fCharacterView->IsShowingContainedBlocksOnly()); #endif menuBar->AddItem(menu); menuBar->AddItem(_CreateFontMenu()); AddCommonFilter(new EscapeMessageFilter(kMsgClearFilter)); AddCommonFilter(new RedirectUpAndDownFilter(fUnicodeBlockView)); // TODO: why is this needed? fUnicodeBlockView->SetTarget(this); fFilterControl->MakeFocus(); }
ServerConnectWnd::ServerConnectWnd() : CUIWnd(UserString("SCONNECT_WINDOW_TITLE"), (GG::GUI::GetGUI()->AppWidth() - WINDOW_WIDTH) / 2, (GG::GUI::GetGUI()->AppHeight() - WINDOW_HEIGHT) / 2, WINDOW_WIDTH, WINDOW_HEIGHT, GG::INTERACTIVE | GG::MODAL), m_host_or_join_radio_group(0), m_LAN_game_label(0), m_servers_lb(0), m_find_LAN_servers_bn(0), m_internet_game_label(0), m_IP_address_edit(0), m_player_name_edit(0), m_ok_bn(0), m_cancel_bn(0) { Sound::TempUISoundDisabler sound_disabler; boost::shared_ptr<GG::Font> font = ClientUI::GetFont(); GG::TextControl* player_name_label = new GG::TextControl(GG::X0, GG::Y0, GG::X1, GG::Y1, UserString("PLAYER_NAME_LABEL"), font, ClientUI::TextColor(), GG::FORMAT_LEFT); m_player_name_edit = new CUIEdit(GG::X0, GG::Y0, GG::X1, GetOptionsDB().Get<std::string>("multiplayersetup.player-name")); m_host_or_join_radio_group = new GG::RadioButtonGroup(GG::X0, GG::Y0, GG::X1, GG::Y1, GG::VERTICAL); m_host_or_join_radio_group->AddButton(new CUIStateButton(UserString("HOST_GAME_BN"), GG::X0, GG::Y0, GG::X1, GG::Y1, GG::FORMAT_LEFT, GG::SBSTYLE_3D_RADIO)); m_host_or_join_radio_group->AddButton(new CUIStateButton(UserString("JOIN_GAME_BN"), GG::X0, GG::Y0, GG::X1, GG::Y1, GG::FORMAT_LEFT, GG::SBSTYLE_3D_RADIO)); m_LAN_game_label = new GG::TextControl(GG::X0, GG::Y0, UserString("LAN_GAME_LABEL"), font, ClientUI::TextColor(), GG::FORMAT_LEFT); m_servers_lb = new CUIListBox(GG::X0, GG::Y0, GG::X1, GG::Y1); m_servers_lb->SetStyle(GG::LIST_NOSORT | GG::LIST_SINGLESEL); m_find_LAN_servers_bn = new CUIButton(UserString("REFRESH_LIST_BN")); m_internet_game_label = new GG::TextControl(GG::X0, GG::Y0, UserString("INTERNET_GAME_LABEL"), font, ClientUI::TextColor(), GG::FORMAT_LEFT); m_IP_address_edit = new CUIEdit(GG::X0, GG::Y0, GG::X1, GetOptionsDB().Get<std::string>("multiplayersetup.host-address")); m_ok_bn = new CUIButton(UserString("OK")); m_cancel_bn = new CUIButton(UserString("CANCEL")); const GG::X OK_CANCEL_BUTTON_WIDTH(80); const int CONTROL_MARGIN = 5; GG::Layout* layout = new GG::Layout(GG::X0, GG::Y0, GG::X1, GG::Y1, 8, 4, CONTROL_MARGIN); layout->SetMinimumColumnWidth(0, player_name_label->MinUsableSize().x + CONTROL_MARGIN); layout->SetColumnStretch(1, 1.0); layout->SetMinimumColumnWidth(2, OK_CANCEL_BUTTON_WIDTH + CONTROL_MARGIN); layout->SetMinimumColumnWidth(3, OK_CANCEL_BUTTON_WIDTH + CONTROL_MARGIN); layout->SetMinimumRowHeight(0, m_player_name_edit->Height() + CONTROL_MARGIN); layout->SetMinimumRowHeight(1, m_host_or_join_radio_group->MinUsableSize().y); layout->SetMinimumRowHeight(2, m_LAN_game_label->Height() + (2 * CONTROL_MARGIN)); layout->SetRowStretch(3, 1.0); layout->SetMinimumRowHeight(4, m_find_LAN_servers_bn->Height() + CONTROL_MARGIN); layout->SetMinimumRowHeight(5, m_internet_game_label->Height() + CONTROL_MARGIN); layout->SetMinimumRowHeight(6, m_IP_address_edit->Height() + CONTROL_MARGIN); layout->SetMinimumRowHeight(7, m_ok_bn->Height() + CONTROL_MARGIN); layout->Add(player_name_label, 0, 0, 1, 1, GG::ALIGN_VCENTER); layout->Add(m_player_name_edit, 0, 1, 1, 3, GG::ALIGN_VCENTER); layout->Add(m_host_or_join_radio_group, 1, 0, 1, 4); layout->Add(m_LAN_game_label, 2, 0, 1, 4, GG::ALIGN_BOTTOM); layout->Add(m_servers_lb, 3, 0, 1, 4); layout->Add(m_find_LAN_servers_bn, 4, 3); layout->Add(m_internet_game_label, 5, 0, 1, 4); layout->Add(m_IP_address_edit, 6, 0, 1, 4); layout->Add(m_ok_bn, 7, 2); layout->Add(m_cancel_bn, 7, 3); SetLayout(layout); m_LAN_servers = HumanClientApp::GetApp()->Networking().DiscoverLANServers(); Init(); }
AboutView::AboutView() : BView("aboutview", B_WILL_DRAW | B_PULSE_NEEDED), fLastActionTime(system_time()), fScrollRunner(NULL) { // Begin Construction of System Information controls system_info systemInfo; get_system_info(&systemInfo); // Create all the various labels for system infomation // OS Version char string[1024]; strcpy(string, B_TRANSLATE("Unknown")); // the version is stored in the BEOS:APP_VERSION attribute of libbe.so BPath path; if (find_directory(B_BEOS_LIB_DIRECTORY, &path) == B_OK) { path.Append("libbe.so"); BAppFileInfo appFileInfo; version_info versionInfo; BFile file; if (file.SetTo(path.Path(), B_READ_ONLY) == B_OK && appFileInfo.SetTo(&file) == B_OK && appFileInfo.GetVersionInfo(&versionInfo, B_APP_VERSION_KIND) == B_OK && versionInfo.short_info[0] != '\0') strcpy(string, versionInfo.short_info); } // Add revision from uname() info utsname unameInfo; if (uname(&unameInfo) == 0) { long revision; if (sscanf(unameInfo.version, "r%ld", &revision) == 1) { char version[16]; snprintf(version, sizeof(version), "%ld", revision); strlcat(string, " (", sizeof(string)); strlcat(string, B_TRANSLATE("Revision"), sizeof(string)); strlcat(string, " ", sizeof(string)); strlcat(string, version, sizeof(string)); strlcat(string, ")", sizeof(string)); } } BStringView* versionView = new BStringView("ostext", string); versionView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); // GCC version BEntry gccFourHybrid("/boot/system/lib/gcc2/libstdc++.r4.so"); BEntry gccTwoHybrid("/boot/system/lib/gcc4/libsupc++.so"); if (gccFourHybrid.Exists() || gccTwoHybrid.Exists()) snprintf(string, sizeof(string), B_TRANSLATE("GCC %d Hybrid"), __GNUC__); else snprintf(string, sizeof(string), "GCC %d", __GNUC__); BStringView* gccView = new BStringView("gcctext", string); gccView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); // CPU count, type and clock speed char processorLabel[256]; if (systemInfo.cpu_count > 1) { snprintf(processorLabel, sizeof(processorLabel), B_TRANSLATE("%ld Processors:"), systemInfo.cpu_count); } else strlcpy(processorLabel, B_TRANSLATE("Processor:"), sizeof(processorLabel)); BString cpuType; cpuType << get_cpu_vendor_string(systemInfo.cpu_type) << " " << get_cpu_model_string(&systemInfo); BStringView* cpuView = new BStringView("cputext", cpuType.String()); cpuView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); int32 clockSpeed = get_rounded_cpu_speed(); if (clockSpeed < 1000) sprintf(string, B_TRANSLATE("%ld MHz"), clockSpeed); else sprintf(string, B_TRANSLATE("%.2f GHz"), clockSpeed / 1000.0f); BStringView* frequencyView = new BStringView("frequencytext", string); frequencyView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); // RAM BStringView *memSizeView = new BStringView("ramsizetext", MemSizeToString(string, sizeof(string), &systemInfo)); memSizeView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); fMemView = new BStringView("ramtext", MemUsageToString(string, sizeof(string), &systemInfo)); fMemView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); // Kernel build time/date snprintf(string, sizeof(string), "%s %s", systemInfo.kernel_build_date, systemInfo.kernel_build_time); BStringView* kernelView = new BStringView("kerneltext", string); kernelView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET)); // Uptime fUptimeView = new BTextView("uptimetext"); fUptimeView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fUptimeView->MakeEditable(false); fUptimeView->MakeSelectable(false); fUptimeView->SetWordWrap(true); fUptimeView->SetText(UptimeToString(string, sizeof(string))); const float offset = 5; SetLayout(new BGroupLayout(B_HORIZONTAL)); BLayoutBuilder::Group<>((BGroupLayout*)GetLayout()) .AddGroup(B_VERTICAL) .Add(new LogoView()) .AddGroup(B_VERTICAL) .Add(_CreateLabel("oslabel", B_TRANSLATE("Version:"))) .Add(versionView) .Add(gccView) .AddStrut(offset) .Add(_CreateLabel("cpulabel", processorLabel)) .Add(cpuView) .Add(frequencyView) .AddStrut(offset) .Add(_CreateLabel("memlabel", B_TRANSLATE("Memory:"))) .Add(memSizeView) .Add(fMemView) .AddStrut(offset) .Add(_CreateLabel("kernellabel", B_TRANSLATE("Kernel:"))) .Add(kernelView) .AddStrut(offset) .Add(_CreateLabel("uptimelabel", B_TRANSLATE("Time running:"))) .Add(fUptimeView) .SetInsets(5, 5, 5, 5) .End() // TODO: investigate: adding this causes the time to be cut //.AddGlue() .End() .Add(_CreateCreditsView()); float min = fMemView->MinSize().width * 1.1f; fCreditsView->SetExplicitMinSize(BSize(min, min)); }
void pawsStdTreeLayout::SetVertScroll(int _vertScroll) { vertScroll = _vertScroll; SetLayout(); }
DownloadWindow::DownloadWindow(BRect frame, bool visible, SettingsMessage* settings) : BWindow(frame, B_TRANSLATE("Downloads"), B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE), fMinimizeOnClose(false) { SetPulseRate(1000000); settings->AddListener(BMessenger(this)); BPath downloadPath; if (find_directory(B_DESKTOP_DIRECTORY, &downloadPath) != B_OK) downloadPath.SetTo("/boot/home/Desktop"); fDownloadPath = settings->GetValue(kSettingsKeyDownloadPath, downloadPath.Path()); settings->SetValue(kSettingsKeyDownloadPath, fDownloadPath); SetLayout(new BGroupLayout(B_VERTICAL, 0.0)); DownloadsContainerView* downloadsGroupView = new DownloadsContainerView(); fDownloadViewsLayout = downloadsGroupView->GroupLayout(); BMenuBar* menuBar = new BMenuBar("Menu bar"); BMenu* menu = new BMenu(B_TRANSLATE("Downloads")); menu->AddItem(new BMenuItem(B_TRANSLATE("Open downloads folder"), new BMessage(OPEN_DOWNLOADS_FOLDER))); BMessage* newWindowMessage = new BMessage(NEW_WINDOW); newWindowMessage->AddString("url", ""); BMenuItem* newWindowItem = new BMenuItem(B_TRANSLATE("New browser window"), newWindowMessage, 'N'); menu->AddItem(newWindowItem); newWindowItem->SetTarget(be_app); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Hide"), new BMessage(B_QUIT_REQUESTED), 'D')); menuBar->AddItem(menu); fDownloadsScrollView = new DownloadContainerScrollView(downloadsGroupView); fRemoveFinishedButton = new BButton(B_TRANSLATE("Remove finished"), new BMessage(REMOVE_FINISHED_DOWNLOADS)); fRemoveFinishedButton->SetEnabled(false); fRemoveMissingButton = new BButton(B_TRANSLATE("Remove missing"), new BMessage(REMOVE_MISSING_DOWNLOADS)); fRemoveMissingButton->SetEnabled(false); const float spacing = be_control_look->DefaultItemSpacing(); AddChild(BGroupLayoutBuilder(B_VERTICAL, 0.0) .Add(menuBar) .Add(fDownloadsScrollView) .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER)) .Add(BGroupLayoutBuilder(B_HORIZONTAL, spacing) .AddGlue() .Add(fRemoveMissingButton) .Add(fRemoveFinishedButton) .SetInsets(12, 5, 12, 5) ) ); PostMessage(INIT); if (!visible) Hide(); Show(); }