BView* SettingsWindow::_CreateFontsPage(float spacing) { fStandardFontView = new FontSelectionView("standard", B_TRANSLATE("Standard font:"), true, be_plain_font); BFont defaultSerifFont = _FindDefaultSerifFont(); fSerifFontView = new FontSelectionView("serif", B_TRANSLATE("Serif font:"), true, &defaultSerifFont); fSansSerifFontView = new FontSelectionView("sans serif", B_TRANSLATE("Sans serif font:"), true, be_plain_font); fFixedFontView = new FontSelectionView("fixed", B_TRANSLATE("Fixed font:"), true, be_fixed_font); fStandardSizesMenu = new BMenuField("standard font size", B_TRANSLATE("Default standard font size:"), new BPopUpMenu("sizes"), B_WILL_DRAW); _BuildSizesMenu(fStandardSizesMenu->Menu(), MSG_STANDARD_FONT_SIZE_SELECTED); fFixedSizesMenu = new BMenuField("fixed font size", B_TRANSLATE("Default fixed font size:"), new BPopUpMenu("sizes"), B_WILL_DRAW); _BuildSizesMenu(fFixedSizesMenu->Menu(), MSG_FIXED_FONT_SIZE_SELECTED); BView* view = BGridLayoutBuilder(spacing / 2, spacing / 2) .Add(fStandardFontView->CreateFontsLabelLayoutItem(), 0, 0) .Add(fStandardFontView->CreateFontsMenuBarLayoutItem(), 1, 0) .Add(fStandardFontView->PreviewBox(), 0, 1, 2) .Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing), 0, 2, 2) .Add(fSerifFontView->CreateFontsLabelLayoutItem(), 0, 3) .Add(fSerifFontView->CreateFontsMenuBarLayoutItem(), 1, 3) .Add(fSerifFontView->PreviewBox(), 0, 4, 2) .Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing), 0, 5, 2) .Add(fSansSerifFontView->CreateFontsLabelLayoutItem(), 0, 6) .Add(fSansSerifFontView->CreateFontsMenuBarLayoutItem(), 1, 6) .Add(fSansSerifFontView->PreviewBox(), 0, 7, 2) .Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing), 0, 8, 2) .Add(fFixedFontView->CreateFontsLabelLayoutItem(), 0, 9) .Add(fFixedFontView->CreateFontsMenuBarLayoutItem(), 1, 9) .Add(fFixedFontView->PreviewBox(), 0, 10, 2) .Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing), 0, 11, 2) .Add(fStandardSizesMenu->CreateLabelLayoutItem(), 0, 12) .Add(fStandardSizesMenu->CreateMenuBarLayoutItem(), 1, 12) .Add(fFixedSizesMenu->CreateLabelLayoutItem(), 0, 13) .Add(fFixedSizesMenu->CreateMenuBarLayoutItem(), 1, 13) .SetInsets(spacing, spacing, spacing, spacing) .View() ; view->SetName(B_TRANSLATE("Fonts")); return view; }
BView* SettingsWindow::_CreateFontsPage(float spacing) { fStandardFontView = new FontSelectionView("standard", B_TRANSLATE("Standard font:"), true, be_plain_font); BFont defaultSerifFont = _FindDefaultSerifFont(); fSerifFontView = new FontSelectionView("serif", B_TRANSLATE("Serif font:"), true, &defaultSerifFont); fSansSerifFontView = new FontSelectionView("sans serif", B_TRANSLATE("Sans serif font:"), true, be_plain_font); fFixedFontView = new FontSelectionView("fixed", B_TRANSLATE("Fixed font:"), true, be_fixed_font); fStandardSizesSpinner = new BSpinner("standard font size", B_TRANSLATE("Default standard font size:"), new BMessage(MSG_STANDARD_FONT_SIZE_SELECTED)); fStandardSizesSpinner->SetAlignment(B_ALIGN_RIGHT); fFixedSizesSpinner = new BSpinner("fixed font size", B_TRANSLATE("Default fixed font size:"), new BMessage(MSG_FIXED_FONT_SIZE_SELECTED)); fFixedSizesSpinner->SetAlignment(B_ALIGN_RIGHT); BView* view = BGridLayoutBuilder(spacing / 2, spacing / 2) .Add(fStandardFontView->CreateFontsLabelLayoutItem(), 0, 0) .Add(fStandardFontView->CreateFontsMenuBarLayoutItem(), 1, 0) .Add(fStandardSizesSpinner->CreateLabelLayoutItem(), 2, 0) .Add(fStandardSizesSpinner->CreateTextViewLayoutItem(), 3, 0) .Add(fStandardFontView->PreviewBox(), 1, 1, 3) .Add(fSerifFontView->CreateFontsLabelLayoutItem(), 0, 2) .Add(fSerifFontView->CreateFontsMenuBarLayoutItem(), 1, 2) .Add(fSerifFontView->PreviewBox(), 1, 3, 3) .Add(fSansSerifFontView->CreateFontsLabelLayoutItem(), 0, 4) .Add(fSansSerifFontView->CreateFontsMenuBarLayoutItem(), 1, 4) .Add(fSansSerifFontView->PreviewBox(), 1, 5, 3) .Add(BSpaceLayoutItem::CreateVerticalStrut(spacing / 2), 0, 6, 2) .Add(fFixedFontView->CreateFontsLabelLayoutItem(), 0, 7) .Add(fFixedFontView->CreateFontsMenuBarLayoutItem(), 1, 7) .Add(fFixedSizesSpinner->CreateLabelLayoutItem(), 2, 7) .Add(fFixedSizesSpinner->CreateTextViewLayoutItem(), 3, 7) .Add(fFixedFontView->PreviewBox(), 1, 8, 3) .SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING) .View(); view->SetName(B_TRANSLATE("Fonts")); return view; }
BView* SettingsWindow::_CreateProxyPage(float spacing) { fUseProxyCheckBox = new BCheckBox("use proxy", B_TRANSLATE("Use proxy server to connect to the internet."), new BMessage(MSG_USE_PROXY_CHANGED)); fUseProxyCheckBox->SetValue(B_CONTROL_ON); fProxyAddressControl = new BTextControl("proxy address", B_TRANSLATE("Proxy server address:"), "", new BMessage(MSG_PROXY_ADDRESS_CHANGED)); fProxyAddressControl->SetModificationMessage( new BMessage(MSG_PROXY_ADDRESS_CHANGED)); fProxyAddressControl->SetText( fSettings->GetValue(kSettingsKeyProxyAddress, "")); fProxyPortControl = new BTextControl("proxy port", B_TRANSLATE("Proxy server port:"), "", new BMessage(MSG_PROXY_PORT_CHANGED)); fProxyPortControl->SetModificationMessage( new BMessage(MSG_PROXY_PORT_CHANGED)); fProxyPortControl->SetText( fSettings->GetValue(kSettingsKeyProxyAddress, "")); BView* view = BGroupLayoutBuilder(B_VERTICAL, spacing / 2) .Add(fUseProxyCheckBox) .Add(BGridLayoutBuilder(spacing / 2, spacing / 2) .Add(fProxyAddressControl->CreateLabelLayoutItem(), 0, 0) .Add(fProxyAddressControl->CreateTextViewLayoutItem(), 1, 0) .Add(fProxyPortControl->CreateLabelLayoutItem(), 0, 1) .Add(fProxyPortControl->CreateTextViewLayoutItem(), 1, 1) ) .Add(BSpaceLayoutItem::CreateGlue()) .SetInsets(spacing, spacing, spacing, spacing) .TopView() ; view->SetName(B_TRANSLATE("Proxy server")); return view; }
int main(int argc, char** argv) { BApplication app("application/x-vnd.antares-look"); BWindow* window = new Window(BRect(50, 50, 100, 100), "Look at these pretty controls!", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS | B_QUIT_ON_WINDOW_CLOSE); window->SetLayout(new BGroupLayout(B_HORIZONTAL)); // create some controls // BListView BListView* listView = new BListView(); for (int32 i = 0; i < 20; i++) { BString itemLabel("List item "); itemLabel << i + 1; listView->AddItem(new BStringItem(itemLabel.String())); } BScrollView* scrollView = new BScrollView("scroller", listView, 0, true, true); scrollView->SetExplicitMinSize(BSize(300, 140)); // BColumnListView BColumnListView* columnListView = new BColumnListView("clv", 0, B_FANCY_BORDER); // for (int32 i = 0; i < 20; i++) { // BString itemLabel("List Item "); // itemLabel << i + 1; // columnListView->AddItem(new BStringItem(itemLabel.String())); // } BGridView* controls = new BGridView(kInset, kInset); BGridLayout* layout = controls->GridLayout(); controls->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)); int32 row = 0; add_controls<BButton>(layout, row); add_controls<BCheckBox>(layout, row); add_controls<BRadioButton>(layout, row); add_menu_fields(layout, row); add_text_controls(layout, row); add_sliders(layout, row); add_status_bars(layout, row); BColorControl* colorControl = new BColorControl(B_ORIGIN, B_CELLS_32x8, 8.0f, "color control"); layout->AddView(colorControl, 0, row, 4); BTabView* tabView = new BTabView("tab view", B_WIDTH_FROM_WIDEST); BView* content = BGroupLayoutBuilder(B_VERTICAL, kInset) .Add(scrollView) .Add(columnListView) .Add(controls) .SetInsets(kInset, kInset, kInset, kInset); content->SetName("Tab 1"); tabView->AddTab(content); BView* tab2 = new BView("Tab 2", 0); tab2->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); tabView->AddTab(tab2); tabView->AddTab(new BView("Tab 3", 0)); BMenuBar* menuBar = new BMenuBar("menu bar"); BMenu* menu = new BMenu("File"); menu->AddItem(new BMenuItem("Test Open BFilePanel", new BMessage(MSG_TEST_OPEN_FILE_PANEL))); menu->AddItem(new BMenuItem("Test Save BFilePanel", new BMessage(MSG_TEST_SAVE_FILE_PANEL))); menu->AddItem(new BMenuItem("Click me!", NULL)); menu->AddItem(new BMenuItem("Another option", NULL)); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED))); menuBar->AddItem(menu); menu = new BMenu("Edit"); menu->SetEnabled(false); menu->AddItem(new BMenuItem("Cut", NULL)); menu->AddItem(new BMenuItem("Copy", NULL)); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("Past", NULL)); menuBar->AddItem(menu); menu = new BMenu("One Item"); menu->AddItem(new BMenuItem("Only", NULL)); menuBar->AddItem(menu); menu = new BMenu("Sub Menu"); BMenu* subMenu = new BMenu("Click me"); subMenu->AddItem(new BMenuItem("Either", NULL)); subMenu->AddItem(new BMenuItem("Or", NULL)); subMenu->SetRadioMode(true); menu->AddItem(subMenu); menuBar->AddItem(menu); BButton* okButton = new BButton("OK", new BMessage(B_QUIT_REQUESTED)); window->AddChild(BGroupLayoutBuilder(B_VERTICAL) .Add(menuBar) .Add(BGroupLayoutBuilder(B_VERTICAL, kInset) .Add(tabView) .Add(BGroupLayoutBuilder(B_HORIZONTAL, kInset) .Add(new BButton("Revert", new BMessage(MSG_TOGGLE_LOOK))) .Add(BSpaceLayoutItem::CreateGlue()) .Add(new BButton("Cancel", NULL)) .Add(okButton) ) .SetInsets(kInset, kInset, kInset, kInset) ) ); window->SetDefaultButton(okButton); window->Show(); app.Run(); return 0; }
BView* PreferencesWindow::_CreateConnectionPage(float spacing) { /* BStringView* addingLabel = new BStringView("", B_TRANSLATE("Adding")); BStringView* downloadingLabel = new BStringView("", B_TRANSLATE("Downloading")); //BStringView* seedingLabel = new BStringView("", B_TRANSLATE("Seeding Limits")); addingLabel->SetFont(be_bold_font); downloadingLabel->SetFont(be_bold_font); */ BStringView* peerPortLabel = new BStringView("", B_TRANSLATE("Peer Port")); BStringView* limitsLabel = new BStringView("", B_TRANSLATE("Limits")); BStringView* otherLabel = new BStringView("", B_TRANSLATE("Other")); peerPortLabel->SetFont(be_bold_font); limitsLabel->SetFont(be_bold_font); otherLabel->SetFont(be_bold_font); BStringView* fListeningPortLabel = new BStringView("", B_TRANSLATE("Incoming port:")); BStringView* fMaxConnectionLabel = new BStringView("", B_TRANSLATE("Max connections:")); BStringView* fTorrentMaxConnectionLabel = new BStringView("", B_TRANSLATE("Connected peers limit:")); //BStringView* fTorrentUploadSlotsLabel = new BStringView("", B_TRANSLATE("Connected peers per torrent limit:")); fListeningPort = new BTextControl("_name", NULL, "", NULL); fRandomPort = new BButton("", B_TRANSLATE("Random"), new BMessage(MSG_INCOMING_PORT_RANDOM_BEHAVIOR_CHANGED)); fApplyPort = new BButton("", B_TRANSLATE("Apply"), new BMessage(MSG_INCOMING_PORT_BEHAVIOR_CHANGED)); fEnableForwardingPort = new BCheckBox("", B_TRANSLATE("Enable UPnP / NAT-PMP port forwarding"), new BMessage(MSG_PORT_FORWARDING_BEHAVIOR_CHANGED)); fMaxConnection = new BTextControl("_name", "", "", NULL); fApplyMaxConnection = new BButton("", B_TRANSLATE("Apply"), new BMessage(MSG_PEER_LIMIT_BEHAVIOR_CHANGED)); fTorrentMaxConnection = new BTextControl("_name", "", "", NULL); fApplyTorrentMaxConnection = new BButton("", B_TRANSLATE("Apply"), new BMessage(MSG_PEER_LIMIT_PER_TORRENT_BEHAVIOR_CHANGED)); //BTextControl* fTorrentUploadSlots = new BTextControl("_name", "", "", NULL); BCheckBox* fEnableDHTValue = new BCheckBox("", B_TRANSLATE("Enable Distributed Hash Table (DHT)"), new BMessage(MSG_DISTRIBUTED_HASH_TABLE_BEHAVIOR_CHANGED)); BCheckBox* fEnablePEXValue = new BCheckBox("", B_TRANSLATE("Enable Bit Torrent Peer EXchange (PEX)"), new BMessage(MSG_TORRENT_PEER_EXCHANGE_BEHAVIOR_CHANGED)); BCheckBox* fEnableUTPValue = new BCheckBox("", B_TRANSLATE("Enable Micro Transport Protocol (" UTF8_GREEK_MU_LETTER "TP)"), new BMessage(MSG_MICRO_TRANSPORT_PROTOCOL_BEHAVIOR_CHANGED)); BCheckBox* fEnableLPDValue = new BCheckBox("", B_TRANSLATE("Enable Local Peer Discovery (LPD)"), new BMessage(MSG_LOCAL_PEER_DISCOVERY_BEHAVIOR_CHANGED)); // BPopUpMenu* menu = new BPopUpMenu(""); fEncryptionMenuItem[0] = new BMenuItem(B_TRANSLATE("Off"), _CreateEncryptionMenuMessage(0)); fEncryptionMenuItem[1] = new BMenuItem(B_TRANSLATE("Enabled"), _CreateEncryptionMenuMessage(1)); fEncryptionMenuItem[2] = new BMenuItem(B_TRANSLATE("Required"), _CreateEncryptionMenuMessage(2)); menu->AddItem(fEncryptionMenuItem[0]); menu->AddItem(fEncryptionMenuItem[1]); menu->AddItem(fEncryptionMenuItem[2]); fEncryptionMenu = new BMenuField("", B_TRANSLATE("Encryption:"), menu); // BString textBuffer; textBuffer << (int32)fTorrentPreferences->IncomingPort(); fListeningPort->SetText(textBuffer); textBuffer = B_EMPTY_STRING; textBuffer << (int32)fTorrentPreferences->PeerLimit(); fMaxConnection->SetText(textBuffer); textBuffer = B_EMPTY_STRING; textBuffer << (int32)fTorrentPreferences->PeerLimitPerTorrent(); fTorrentMaxConnection->SetText(textBuffer); //textBuffer << (int32)fTorrentPreferences->IncomingPort(); //fTorrentUploadSlots->SetText(textBuffer); fEnableForwardingPort->SetValue(fTorrentPreferences->PortForwardingEnabled() ? B_CONTROL_ON : B_CONTROL_OFF); fEnableDHTValue->SetValue(fTorrentPreferences->DistributedHashTableEnabled() ? B_CONTROL_ON : B_CONTROL_OFF); fEnablePEXValue->SetValue(fTorrentPreferences->PeerExchangeEnabled() ? B_CONTROL_ON : B_CONTROL_OFF); fEnableUTPValue->SetValue(fTorrentPreferences->MicroTransportProtocolEnabled() ? B_CONTROL_ON : B_CONTROL_OFF); fEnableLPDValue->SetValue(fTorrentPreferences->LocalPeerDiscoveryEnabled() ? B_CONTROL_ON : B_CONTROL_OFF); fEncryptionMenuItem[fTorrentPreferences->EncryptionMode()]->SetMarked(true); // fListeningPort->SetExplicitMaxSize(BSize(60, 40)); fMaxConnection->SetExplicitMaxSize(BSize(60, 40)); fTorrentMaxConnection->SetExplicitMaxSize(BSize(60, 40)); //fTorrentUploadSlots->SetExplicitMaxSize(BSize(60, 40)); // // BView* view = BGroupLayoutBuilder(B_VERTICAL, spacing / 2) .Add(peerPortLabel) .Add(BGridLayoutBuilder(-1, spacing / 2) .SetInsets(spacing / 2, -1, -1, -1) .Add(fListeningPortLabel, 0, 0) //.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing), 1, 0) .Add(fListeningPort, 1, 0) .Add(fRandomPort, 2, 0) .Add(fApplyPort, 3, 0) //.Add(BSpaceLayoutItem::CreateGlue(), 2, 0) //.Add(BSpaceLayoutItem::CreateGlue(), 3, 0) //.Add(BSpaceLayoutItem::CreateGlue(), 4, 0) // .Add(fEnableForwardingPort, 0, 1, 3, 1) // ) .Add(limitsLabel) .Add(BGridLayoutBuilder(spacing / 2, spacing / 2) .SetInsets(spacing / 2, -1, -1, -1) .Add(fMaxConnectionLabel, 0, 0) .Add(fMaxConnection, 1, 0) .Add(fApplyMaxConnection, 2, 0) // padding //.Add(BSpaceLayoutItem::CreateGlue(), 3, 0) //.Add(BSpaceLayoutItem::CreateGlue(), 4, 0) // .Add(fTorrentMaxConnectionLabel, 0, 1) .Add(fTorrentMaxConnection, 1, 1) .Add(fApplyTorrentMaxConnection, 2, 1) // //.Add(fTorrentUploadSlotsLabel, 0, 2) //.Add(fTorrentUploadSlots, 1, 2) ) .Add(otherLabel) .Add(BGridLayoutBuilder(spacing / 2, spacing / 2) .SetInsets(spacing / 2, -1, -1, -1) .Add(fEnableDHTValue, 0, 0, 3, 1) .Add(fEnablePEXValue, 0, 1, 3, 1) .Add(fEnableUTPValue, 0, 2, 3, 1) .Add(fEnableLPDValue, 0, 3, 3, 1) // .Add(fEncryptionMenu->CreateLabelLayoutItem(), 0, 4) .Add(fEncryptionMenu->CreateMenuBarLayoutItem(), 1, 4) ) .SetInsets(spacing, spacing, spacing, spacing) .TopView() ; view->SetName("Connection"); return view; }
BView* PreferencesWindow::_CreateTorrentsPage(float spacing) { BStringView* addingLabel = new BStringView("", B_TRANSLATE("Adding")); BStringView* downloadingLabel = new BStringView("", B_TRANSLATE("Downloading")); //BStringView* seedingLabel = new BStringView("", B_TRANSLATE("Seeding Limits")); addingLabel->SetFont(be_bold_font); downloadingLabel->SetFont(be_bold_font); // // // //fAutoAddTorrentsFrom = new BCheckBox("auto_add_torrents_from", // B_TRANSLATE("Automatically add torrents from:"), // new BMessage(MSG_ADD_TORRENT_FROM_FOLDER_CHANGED)); //fAutoAddTorrentsFrom->SetValue(B_CONTROL_OFF); // // //fAutoAddTorrentsFromFolder = new FolderSelect("auto_add_torrents_from_folder", // NULL, "/test/path"/*new BMessage(MSG_DOWNLOAD_FOLDER_CHANGED)*/); // //fAutoAddTorrentsFromFolder->SetEnabled(false); BCheckBox* fShowOptionsDialog = new BCheckBox("Show options dialog", B_TRANSLATE("Show options dialog"), NULL /*new BMessage(MSG_AUTO_HIDE_INTERFACE_BEHAVIOR_CHANGED)*/); fShowOptionsDialog->SetValue(B_CONTROL_OFF); BCheckBox* fStartWhenAdded = new BCheckBox("start_when_added", B_TRANSLATE("Start when added"), new BMessage(MSG_START_WHEN_ADDED_BEHAVIOR_CHANGED)); fStartWhenAdded->SetValue(fTorrentPreferences->StartWhenAddedEnabled() ? B_CONTROL_ON : B_CONTROL_OFF); fIncompleteFileNaming = new BCheckBox("incomplete_file_naming", B_TRANSLATE("Append \".part\" to incomplete files' names"), new BMessage(MSG_INCOMPLETE_FILENAMING_BEHAVIOR_CHANGED)); fIncompleteFileNaming->SetValue(fTorrentPreferences->IncompleteFileNamingEnabled() ? B_CONTROL_ON : B_CONTROL_OFF); BStringView* fTorrentSaveLocation = new BStringView("", B_TRANSLATE("Save to Location:")); fTorrentSaveLocationPath = new FolderSelect("download_folder_select", fTorrentPreferences->DownloadFolder(), new BMessage(MSG_DOWNLOAD_FOLDER_BEHAVIOR_CHANGED)); fIncompleteDirEnabled = new BCheckBox("incomplete_torrent_folder", B_TRANSLATE("Incomplete torrents folder"), new BMessage(MSG_INCOMPLETE_FOLDER_BEHAVIOR_CHANGED)); fIncompleteDirEnabled->SetValue(fTorrentPreferences->IncompleteFolderEnabled() ? B_CONTROL_ON : B_CONTROL_OFF); fIncompleteDirPath = new FolderSelect("incomplete_torrent_folder_path", fTorrentPreferences->IncompleteFolder(), new BMessage(MSG_INCOMPLETE_FOLDER_PATH_BEHAVIOR_CHANGED)); fIncompleteDirPath->SetEnabled(fTorrentPreferences->IncompleteFolderEnabled()); // // // BView* view = BGroupLayoutBuilder(B_VERTICAL, spacing / 2) .Add(addingLabel) //.Add(BGridLayoutBuilder(spacing / 2, spacing / 2) // .Add(fAutoAddTorrentsFrom, 0, 0) // .Add(fAutoAddTorrentsFromFolder, 1, 0) //) .Add(BGridLayoutBuilder(spacing, spacing / 2) .SetInsets(spacing / 2, -1, -1, -1) .Add(fShowOptionsDialog, 0, 0) .Add(fStartWhenAdded, 0, 1) ) .Add(downloadingLabel) .Add(BGridLayoutBuilder(spacing, spacing / 2) .SetInsets(spacing / 2, -1, -1, -1) .Add(fIncompleteFileNaming, 0, 0, 2, 1) .Add(fTorrentSaveLocation, 0, 1) .Add(fTorrentSaveLocationPath, 1, 1) .Add(fIncompleteDirEnabled, 0, 2) .Add(fIncompleteDirPath, 1, 2) ) .Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing)) .SetInsets(spacing, spacing, spacing, spacing) .TopView() ; view->SetName("Torrents"); return view; }
BView* SettingsWindow::_CreateGeneralPage(float spacing) { fStartPageControl = new BTextControl("start page", B_TRANSLATE("Start page:"), "", new BMessage(MSG_START_PAGE_CHANGED)); fStartPageControl->SetModificationMessage( new BMessage(MSG_START_PAGE_CHANGED)); fStartPageControl->SetText( fSettings->GetValue(kSettingsKeyStartPageURL, kDefaultStartPageURL)); fSearchPageControl = new BTextControl("search page", B_TRANSLATE("Search page:"), "", new BMessage(MSG_SEARCH_PAGE_CHANGED)); fSearchPageControl->SetModificationMessage( new BMessage(MSG_SEARCH_PAGE_CHANGED)); fSearchPageControl->SetText( fSettings->GetValue(kSettingsKeySearchPageURL, kDefaultSearchPageURL)); fDownloadFolderControl = new BTextControl("download folder", B_TRANSLATE("Download folder:"), "", new BMessage(MSG_DOWNLOAD_FOLDER_CHANGED)); fDownloadFolderControl->SetModificationMessage( new BMessage(MSG_DOWNLOAD_FOLDER_CHANGED)); fDownloadFolderControl->SetText( fSettings->GetValue(kSettingsKeyDownloadPath, kDefaultDownloadPath)); fNewWindowBehaviorOpenHomeItem = new BMenuItem( B_TRANSLATE("Open start page"), new BMessage(MSG_NEW_WINDOWS_BEHAVIOR_CHANGED)); fNewWindowBehaviorOpenSearchItem = new BMenuItem( B_TRANSLATE("Open search page"), new BMessage(MSG_NEW_WINDOWS_BEHAVIOR_CHANGED)); fNewWindowBehaviorOpenBlankItem = new BMenuItem( B_TRANSLATE("Open blank page"), new BMessage(MSG_NEW_WINDOWS_BEHAVIOR_CHANGED)); fNewTabBehaviorCloneCurrentItem = new BMenuItem( B_TRANSLATE("Clone current page"), new BMessage(MSG_NEW_TABS_BEHAVIOR_CHANGED)); fNewTabBehaviorOpenHomeItem = new BMenuItem( B_TRANSLATE("Open start page"), new BMessage(MSG_NEW_TABS_BEHAVIOR_CHANGED)); fNewTabBehaviorOpenSearchItem = new BMenuItem( B_TRANSLATE("Open search page"), new BMessage(MSG_NEW_TABS_BEHAVIOR_CHANGED)); fNewTabBehaviorOpenBlankItem = new BMenuItem( B_TRANSLATE("Open blank page"), new BMessage(MSG_NEW_TABS_BEHAVIOR_CHANGED)); fNewWindowBehaviorOpenHomeItem->SetMarked(true); fNewTabBehaviorOpenBlankItem->SetMarked(true); BPopUpMenu* newWindowBehaviorMenu = new BPopUpMenu("New windows"); newWindowBehaviorMenu->AddItem(fNewWindowBehaviorOpenHomeItem); newWindowBehaviorMenu->AddItem(fNewWindowBehaviorOpenSearchItem); newWindowBehaviorMenu->AddItem(fNewWindowBehaviorOpenBlankItem); fNewWindowBehaviorMenu = new BMenuField("new window behavior", B_TRANSLATE("New windows:"), newWindowBehaviorMenu); BPopUpMenu* newTabBehaviorMenu = new BPopUpMenu("New tabs"); newTabBehaviorMenu->AddItem(fNewTabBehaviorOpenBlankItem); newTabBehaviorMenu->AddItem(fNewTabBehaviorOpenHomeItem); newTabBehaviorMenu->AddItem(fNewTabBehaviorOpenSearchItem); newTabBehaviorMenu->AddItem(fNewTabBehaviorCloneCurrentItem); fNewTabBehaviorMenu = new BMenuField("new tab behavior", B_TRANSLATE("New tabs:"), newTabBehaviorMenu); fDaysInHistoryMenuControl = new BTextControl("days in history", B_TRANSLATE("Number of days to keep links in History menu:"), "", new BMessage(MSG_HISTORY_MENU_DAYS_CHANGED)); fDaysInHistoryMenuControl->SetModificationMessage( new BMessage(MSG_HISTORY_MENU_DAYS_CHANGED)); BString maxHistoryAge; maxHistoryAge << BrowsingHistory::DefaultInstance()->MaxHistoryItemAge(); fDaysInHistoryMenuControl->SetText(maxHistoryAge.String()); for (uchar i = 0; i < '0'; i++) fDaysInHistoryMenuControl->TextView()->DisallowChar(i); for (uchar i = '9' + 1; i <= 128; i++) fDaysInHistoryMenuControl->TextView()->DisallowChar(i); fShowTabsIfOnlyOnePage = new BCheckBox("show tabs if only one page", B_TRANSLATE("Show tabs if only one page is open"), new BMessage(MSG_TAB_DISPLAY_BEHAVIOR_CHANGED)); fShowTabsIfOnlyOnePage->SetValue(B_CONTROL_ON); fAutoHideInterfaceInFullscreenMode = new BCheckBox("auto-hide interface", B_TRANSLATE("Auto-hide interface in full screen mode"), new BMessage(MSG_AUTO_HIDE_INTERFACE_BEHAVIOR_CHANGED)); fAutoHideInterfaceInFullscreenMode->SetValue(B_CONTROL_OFF); fAutoHidePointer = new BCheckBox("auto-hide pointer", B_TRANSLATE("Auto-hide mouse pointer"), new BMessage(MSG_AUTO_HIDE_POINTER_BEHAVIOR_CHANGED)); fAutoHidePointer->SetValue(B_CONTROL_OFF); fShowHomeButton = new BCheckBox("show home button", B_TRANSLATE("Show home button"), new BMessage(MSG_SHOW_HOME_BUTTON_CHANGED)); fShowHomeButton->SetValue(B_CONTROL_ON); BView* view = BGroupLayoutBuilder(B_VERTICAL, spacing / 2) .Add(BGridLayoutBuilder(spacing / 2, spacing / 2) .Add(fStartPageControl->CreateLabelLayoutItem(), 0, 0) .Add(fStartPageControl->CreateTextViewLayoutItem(), 1, 0) .Add(fSearchPageControl->CreateLabelLayoutItem(), 0, 1) .Add(fSearchPageControl->CreateTextViewLayoutItem(), 1, 1) .Add(fDownloadFolderControl->CreateLabelLayoutItem(), 0, 2) .Add(fDownloadFolderControl->CreateTextViewLayoutItem(), 1, 2) .Add(fNewWindowBehaviorMenu->CreateLabelLayoutItem(), 0, 3) .Add(fNewWindowBehaviorMenu->CreateMenuBarLayoutItem(), 1, 3) .Add(fNewTabBehaviorMenu->CreateLabelLayoutItem(), 0, 4) .Add(fNewTabBehaviorMenu->CreateMenuBarLayoutItem(), 1, 4) ) .Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing)) .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER)) .Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing)) .Add(fShowTabsIfOnlyOnePage) .Add(fAutoHideInterfaceInFullscreenMode) .Add(fAutoHidePointer) .Add(fShowHomeButton) .Add(fDaysInHistoryMenuControl) .Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing)) .SetInsets(spacing, spacing, spacing, spacing) .TopView() ; view->SetName(B_TRANSLATE("General")); return view; }
ErrorWindow::ErrorWindow(BRect frame, ProjectWindow* parent, ErrorList* list) : BWindow(frame, B_TRANSLATE("Errors and warnings"), B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS), fParent(parent), fErrorCount(0), fWarningCount(0) { SetSizeLimits(400, 30000, 250, 30000); MoveTo(100,100); AddShortcut('M', B_COMMAND_KEY, new BMessage(M_MAKE_PROJECT)); AddShortcut('R', B_COMMAND_KEY, new BMessage(M_RUN_PROJECT)); AddShortcut('R', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(M_RUN_IN_TERMINAL)); AddShortcut('R', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage(M_RUN_IN_DEBUGGER)); AddShortcut('R', B_COMMAND_KEY | B_CONTROL_KEY | B_SHIFT_KEY, new BMessage(M_RUN_WITH_ARGS)); AddShortcut('-', B_COMMAND_KEY, new BMessage(M_FORCE_REBUILD)); AddShortcut('I', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); if (list != NULL) fErrors = *list; if (parent != NULL) { BString text = B_TRANSLATE("Errors and warnings: "); text << fParent->GetProject()->GetName(); SetTitle(text.String()); } else debugger("BUG: Invalid project for error window"); BString startingLabel(B_TRANSLATE("Errors")); startingLabel << " (10000)"; fErrorBox = new BCheckBox("errorbox", startingLabel.String(), new BMessage(M_TOGGLE_ERRORS)); fErrorBox->SetLabel(B_TRANSLATE("Errors")); fErrorBox->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER)); startingLabel = B_TRANSLATE("Warnings"); startingLabel << " (10000)"; fWarningBox = new BCheckBox("warningbox", startingLabel.String(), new BMessage(M_TOGGLE_WARNINGS)); fWarningBox->SetLabel("Warnings"); fWarningBox->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER)); fCopyButton = new BButton("copy", B_TRANSLATE("Copy to clipboard"), new BMessage(M_COPY_ERRORS)); fErrorList = new DListView("errorlist", B_SINGLE_SELECTION_LIST, B_WILL_DRAW | B_NAVIGABLE); BScrollView* errorScrollView = fErrorList->MakeScrollView("scroller", true, true); errorScrollView->ScrollBar(B_HORIZONTAL)->SetSteps(25, 75); BPopUpMenu* contextMenu = new BPopUpMenu("context_menu", false, false); contextMenu->AddItem(new BMenuItem(B_TRANSLATE("Copy list to clipboard"), new BMessage(M_COPY_ERRORS))); contextMenu->SetTargetForItems(this); fErrorList->SetContextMenu(contextMenu); BView* header = BLayoutBuilder::Group<>(B_HORIZONTAL) .Add(fErrorBox) .Add(fWarningBox) .Add(fCopyButton) .AddGlue() .SetInsets(B_USE_DEFAULT_SPACING, 0, B_USE_DEFAULT_SPACING, 0) .View(); header->SetName("header"); header->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .Add(header) .Add(errorScrollView) .SetInsets(-1.0f) .End(); if (list != NULL) RefreshList(); BRect newframe; BNode node(fParent->GetProject()->GetPath().GetFullPath()); if (node.ReadAttr("error_frame", B_RECT_TYPE, 0, &newframe, sizeof(newframe))) { if (newframe.left < 100) newframe.left = 100; if (newframe.top < 100) newframe.top = 100; MoveTo(newframe.left, newframe.top); ResizeTo(newframe.Width(), newframe.Height()); } fErrorBox->SetValue(B_CONTROL_ON); fWarningBox->SetValue(B_CONTROL_ON); fErrorList->SetInvocationMessage(new BMessage(M_JUMP_TO_MSG)); fErrorList->MakeFocus(true); }
BView* SettingsWindow::_CreateProxyPage(float spacing) { fUseProxyCheckBox = new BCheckBox("use proxy", B_TRANSLATE("Use proxy server to connect to the internet"), new BMessage(MSG_USE_PROXY_CHANGED)); fUseProxyCheckBox->SetValue(B_CONTROL_ON); fProxyAddressControl = new BTextControl("proxy address", B_TRANSLATE("Proxy server address:"), "", new BMessage(MSG_PROXY_ADDRESS_CHANGED)); fProxyAddressControl->SetModificationMessage( new BMessage(MSG_PROXY_ADDRESS_CHANGED)); fProxyAddressControl->SetText( fSettings->GetValue(kSettingsKeyProxyAddress, "")); fProxyPortControl = new BTextControl("proxy port", B_TRANSLATE("Proxy server port:"), "", new BMessage(MSG_PROXY_PORT_CHANGED)); fProxyPortControl->SetModificationMessage( new BMessage(MSG_PROXY_PORT_CHANGED)); fProxyPortControl->SetText( fSettings->GetValue(kSettingsKeyProxyPort, "")); fUseProxyAuthCheckBox = new BCheckBox("use authentication", B_TRANSLATE("Proxy server requires authentication"), new BMessage(MSG_USE_PROXY_AUTH_CHANGED)); fUseProxyAuthCheckBox->SetValue(B_CONTROL_ON); fProxyUsernameControl = new BTextControl("proxy username", B_TRANSLATE("Proxy username:"******"", new BMessage(MSG_PROXY_USERNAME_CHANGED)); fProxyUsernameControl->SetModificationMessage( new BMessage(MSG_PROXY_USERNAME_CHANGED)); fProxyUsernameControl->SetText( fSettings->GetValue(kSettingsKeyProxyUsername, "")); fProxyPasswordControl = new BTextControl("proxy password", B_TRANSLATE("Proxy password:"******"", new BMessage(MSG_PROXY_PASSWORD_CHANGED)); fProxyPasswordControl->SetModificationMessage( new BMessage(MSG_PROXY_PASSWORD_CHANGED)); fProxyPasswordControl->TextView()->HideTyping(true); fProxyPasswordControl->SetText( fSettings->GetValue(kSettingsKeyProxyPassword, "")); BView* view = BGridLayoutBuilder(spacing / 2, spacing / 2) .Add(fUseProxyCheckBox, 0, 0, 2) .Add(fProxyAddressControl->CreateLabelLayoutItem(), 0, 1) .Add(fProxyAddressControl->CreateTextViewLayoutItem(), 1, 1, 2) .Add(fProxyPortControl->CreateLabelLayoutItem(), 0, 2) .Add(fProxyPortControl->CreateTextViewLayoutItem(), 1, 2, 2) .Add(BSpaceLayoutItem::CreateVerticalStrut(spacing), 0, 3) .Add(fUseProxyAuthCheckBox, 0, 4, 2) .Add(fProxyUsernameControl->CreateLabelLayoutItem(), 0, 5) .Add(fProxyUsernameControl->CreateTextViewLayoutItem(), 1, 5, 2) .Add(fProxyPasswordControl->CreateLabelLayoutItem(), 0, 6) .Add(fProxyPasswordControl->CreateTextViewLayoutItem(), 1, 6, 2) .Add(BSpaceLayoutItem::CreateGlue(), 0, 7) .SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING) .View(); view->SetName(B_TRANSLATE("Proxy server")); return view; }
BView* SettingsWindow::_CreateGeneralPage(float spacing) { fStartPageControl = new BTextControl("start page", B_TRANSLATE("Start page:"), "", new BMessage(MSG_START_PAGE_CHANGED)); fStartPageControl->SetModificationMessage( new BMessage(MSG_START_PAGE_CHANGED)); fStartPageControl->SetText( fSettings->GetValue(kSettingsKeyStartPageURL, kDefaultStartPageURL)); fSearchPageControl = new BTextControl("search page", B_TRANSLATE("Search page:"), "", new BMessage(MSG_SEARCH_PAGE_CHANGED)); fSearchPageControl->SetModificationMessage( new BMessage(MSG_SEARCH_PAGE_CHANGED)); BString searchURL = fSettings->GetValue(kSettingsKeySearchPageURL, kDefaultSearchPageURL); if (searchURL == "http://www.google.com") { // Migrate old settings files. searchURL = kDefaultSearchPageURL; fSettings->SetValue(kSettingsKeySearchPageURL, kDefaultSearchPageURL); } fSearchPageControl->SetText(searchURL); fDownloadFolderControl = new BTextControl("download folder", B_TRANSLATE("Download folder:"), "", new BMessage(MSG_DOWNLOAD_FOLDER_CHANGED)); fDownloadFolderControl->SetModificationMessage( new BMessage(MSG_DOWNLOAD_FOLDER_CHANGED)); fDownloadFolderControl->SetText( fSettings->GetValue(kSettingsKeyDownloadPath, kDefaultDownloadPath)); fStartUpBehaviorResumePriorSession = new BMenuItem( B_TRANSLATE("Resume prior session"), new BMessage(MSG_START_UP_BEHAVIOR_CHANGED)); fStartUpBehaviorStartNewSession = new BMenuItem( B_TRANSLATE("Start new session"), new BMessage(MSG_START_UP_BEHAVIOR_CHANGED)); fNewWindowBehaviorOpenHomeItem = new BMenuItem( B_TRANSLATE("Open start page"), new BMessage(MSG_NEW_WINDOWS_BEHAVIOR_CHANGED)); fNewWindowBehaviorOpenSearchItem = new BMenuItem( B_TRANSLATE("Open search page"), new BMessage(MSG_NEW_WINDOWS_BEHAVIOR_CHANGED)); fNewWindowBehaviorOpenBlankItem = new BMenuItem( B_TRANSLATE("Open blank page"), new BMessage(MSG_NEW_WINDOWS_BEHAVIOR_CHANGED)); fNewTabBehaviorCloneCurrentItem = new BMenuItem( B_TRANSLATE("Clone current page"), new BMessage(MSG_NEW_TABS_BEHAVIOR_CHANGED)); fNewTabBehaviorOpenHomeItem = new BMenuItem( B_TRANSLATE("Open start page"), new BMessage(MSG_NEW_TABS_BEHAVIOR_CHANGED)); fNewTabBehaviorOpenSearchItem = new BMenuItem( B_TRANSLATE("Open search page"), new BMessage(MSG_NEW_TABS_BEHAVIOR_CHANGED)); fNewTabBehaviorOpenBlankItem = new BMenuItem( B_TRANSLATE("Open blank page"), new BMessage(MSG_NEW_TABS_BEHAVIOR_CHANGED)); fChooseButton = new BButton(B_TRANSLATE("Browse" B_UTF8_ELLIPSIS), new BMessage(MSG_CHOOSE_DOWNLOAD_FOLDER)); fNewWindowBehaviorOpenHomeItem->SetMarked(true); fNewTabBehaviorOpenBlankItem->SetMarked(true); fStartUpBehaviorResumePriorSession->SetMarked(true); BPopUpMenu* startUpBehaviorMenu = new BPopUpMenu("Start up"); startUpBehaviorMenu->AddItem(fStartUpBehaviorResumePriorSession); startUpBehaviorMenu->AddItem(fStartUpBehaviorStartNewSession); fStartUpBehaviorMenu = new BMenuField("start up behavior", B_TRANSLATE("Start up:"), startUpBehaviorMenu); BPopUpMenu* newWindowBehaviorMenu = new BPopUpMenu("New windows"); newWindowBehaviorMenu->AddItem(fNewWindowBehaviorOpenHomeItem); newWindowBehaviorMenu->AddItem(fNewWindowBehaviorOpenSearchItem); newWindowBehaviorMenu->AddItem(fNewWindowBehaviorOpenBlankItem); fNewWindowBehaviorMenu = new BMenuField("new window behavior", B_TRANSLATE("New windows:"), newWindowBehaviorMenu); BPopUpMenu* newTabBehaviorMenu = new BPopUpMenu("New tabs"); newTabBehaviorMenu->AddItem(fNewTabBehaviorOpenBlankItem); newTabBehaviorMenu->AddItem(fNewTabBehaviorOpenHomeItem); newTabBehaviorMenu->AddItem(fNewTabBehaviorOpenSearchItem); newTabBehaviorMenu->AddItem(fNewTabBehaviorCloneCurrentItem); fNewTabBehaviorMenu = new BMenuField("new tab behavior", B_TRANSLATE("New tabs:"), newTabBehaviorMenu); fDaysInHistory = new BSpinner("days in history", B_TRANSLATE("Number of days to keep links in History menu:"), new BMessage(MSG_HISTORY_MENU_DAYS_CHANGED)); fDaysInHistory->SetRange(1, 35); fDaysInHistory->SetValue( BrowsingHistory::DefaultInstance()->MaxHistoryItemAge()); fShowTabsIfOnlyOnePage = new BCheckBox("show tabs if only one page", B_TRANSLATE("Show tabs if only one page is open"), new BMessage(MSG_TAB_DISPLAY_BEHAVIOR_CHANGED)); fShowTabsIfOnlyOnePage->SetValue(B_CONTROL_ON); fAutoHideInterfaceInFullscreenMode = new BCheckBox("auto-hide interface", B_TRANSLATE("Auto-hide interface in full screen mode"), new BMessage(MSG_AUTO_HIDE_INTERFACE_BEHAVIOR_CHANGED)); fAutoHideInterfaceInFullscreenMode->SetValue(B_CONTROL_OFF); fAutoHidePointer = new BCheckBox("auto-hide pointer", B_TRANSLATE("Auto-hide mouse pointer"), new BMessage(MSG_AUTO_HIDE_POINTER_BEHAVIOR_CHANGED)); fAutoHidePointer->SetValue(B_CONTROL_OFF); fShowHomeButton = new BCheckBox("show home button", B_TRANSLATE("Show home button"), new BMessage(MSG_SHOW_HOME_BUTTON_CHANGED)); fShowHomeButton->SetValue(B_CONTROL_ON); BView* view = BGroupLayoutBuilder(B_VERTICAL, 0) .Add(BGridLayoutBuilder(spacing / 2, spacing / 2) .Add(fStartPageControl->CreateLabelLayoutItem(), 0, 0) .Add(fStartPageControl->CreateTextViewLayoutItem(), 1, 0) .Add(fSearchPageControl->CreateLabelLayoutItem(), 0, 1) .Add(fSearchPageControl->CreateTextViewLayoutItem(), 1, 1) .Add(fStartUpBehaviorMenu->CreateLabelLayoutItem(), 0, 2) .Add(fStartUpBehaviorMenu->CreateMenuBarLayoutItem(), 1, 2) .Add(fNewWindowBehaviorMenu->CreateLabelLayoutItem(), 0, 3) .Add(fNewWindowBehaviorMenu->CreateMenuBarLayoutItem(), 1, 3) .Add(fNewTabBehaviorMenu->CreateLabelLayoutItem(), 0, 4) .Add(fNewTabBehaviorMenu->CreateMenuBarLayoutItem(), 1, 4) .Add(fDownloadFolderControl->CreateLabelLayoutItem(), 0, 5) .Add(fDownloadFolderControl->CreateTextViewLayoutItem(), 1, 5) .Add(fChooseButton, 2, 5) ) .Add(BSpaceLayoutItem::CreateVerticalStrut(spacing)) .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER)) .Add(BSpaceLayoutItem::CreateVerticalStrut(spacing)) .Add(fShowTabsIfOnlyOnePage) .Add(fAutoHideInterfaceInFullscreenMode) .Add(fAutoHidePointer) .Add(fShowHomeButton) .Add(BSpaceLayoutItem::CreateVerticalStrut(spacing)) .AddGroup(B_HORIZONTAL) .Add(fDaysInHistory) .AddGlue() .End() .AddGlue() .SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING) .TopView() ; view->SetName(B_TRANSLATE("General")); return view; }