AppearancePrefView::AppearancePrefView(const char* name, const BMessenger& messenger) : BGroupView(name, B_VERTICAL, 5), fTerminalMessenger(messenger) { const char* kColorTable[] = { B_TRANSLATE("Text"), B_TRANSLATE("Background"), B_TRANSLATE("Selected text"), B_TRANSLATE("Selected background"), NULL }; fWarnOnExit = new BCheckBox( B_TRANSLATE("Confirm exit if active programs exist"), new BMessage(MSG_WARN_ON_EXIT_CHANGED)); BMenu* fontMenu = _MakeFontMenu(MSG_HALF_FONT_CHANGED, PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY), PrefHandler::Default()->getString(PREF_HALF_FONT_STYLE)); BMenu* sizeMenu = _MakeSizeMenu(MSG_HALF_SIZE_CHANGED, PrefHandler::Default()->getInt32(PREF_HALF_FONT_SIZE)); fFont = new BMenuField(B_TRANSLATE("Font:"), fontMenu); fFontSize = new BMenuField(B_TRANSLATE("Size:"), sizeMenu); BPopUpMenu* schemasPopUp = _MakeColorSchemaMenu(MSG_COLOR_SCHEMA_CHANGED, gPredefinedSchemas, gPredefinedSchemas[0]); fColorSchemaField = new BMenuField(B_TRANSLATE("Color schema:"), schemasPopUp); BPopUpMenu* colorsPopUp = _MakeMenu(MSG_COLOR_FIELD_CHANGED, kColorTable, kColorTable[0]); fColorField = new BMenuField(B_TRANSLATE("Color:"), colorsPopUp); fColorField->SetEnabled(false); fTabTitle = new BTextControl("tabTitle", B_TRANSLATE("Tab title:"), "", NULL); fTabTitle->SetModificationMessage( new BMessage(MSG_TAB_TITLE_SETTING_CHANGED)); fTabTitle->SetToolTip(BString(B_TRANSLATE( "The pattern specifying the tab titles. The following placeholders\n" "can be used:\n")) << kTooTipSetTabTitlePlaceholders); fWindowTitle = new BTextControl("windowTitle", B_TRANSLATE("Window title:"), "", NULL); fWindowTitle->SetModificationMessage( new BMessage(MSG_WINDOW_TITLE_SETTING_CHANGED)); fWindowTitle->SetToolTip(BString(B_TRANSLATE( "The pattern specifying the window titles. The following placeholders\n" "can be used:\n")) << kTooTipSetWindowTitlePlaceholders); BLayoutBuilder::Group<>(this) .SetInsets(5, 5, 5, 5) .AddGrid(5, 5) .Add(fTabTitle->CreateLabelLayoutItem(), 0, 0) .Add(fTabTitle->CreateTextViewLayoutItem(), 1, 0) .Add(fWindowTitle->CreateLabelLayoutItem(), 0, 1) .Add(fWindowTitle->CreateTextViewLayoutItem(), 1, 1) .Add(fFont->CreateLabelLayoutItem(), 0, 2) .Add(fFont->CreateMenuBarLayoutItem(), 1, 2) .Add(fFontSize->CreateLabelLayoutItem(), 0, 3) .Add(fFontSize->CreateMenuBarLayoutItem(), 1, 3) .Add(fColorSchemaField->CreateLabelLayoutItem(), 0, 4) .Add(fColorSchemaField->CreateMenuBarLayoutItem(), 1, 4) .Add(fColorField->CreateLabelLayoutItem(), 0, 5) .Add(fColorField->CreateMenuBarLayoutItem(), 1, 5) .End() .AddGlue() .Add(fColorControl = new BColorControl(BPoint(10, 10), B_CELLS_32x8, 8.0, "", new BMessage(MSG_COLOR_CHANGED))) .Add(fWarnOnExit); fTabTitle->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); fWindowTitle->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); fFont->SetAlignment(B_ALIGN_RIGHT); fFontSize->SetAlignment(B_ALIGN_RIGHT); fColorField->SetAlignment(B_ALIGN_RIGHT); fColorSchemaField->SetAlignment(B_ALIGN_RIGHT); fTabTitle->SetText(PrefHandler::Default()->getString(PREF_TAB_TITLE)); fWindowTitle->SetText(PrefHandler::Default()->getString(PREF_WINDOW_TITLE)); fColorControl->SetEnabled(false); fColorControl->SetValue( PrefHandler::Default()->getRGB(PREF_TEXT_FORE_COLOR)); fWarnOnExit->SetValue(PrefHandler::Default()->getBool(PREF_WARN_ON_EXIT)); BTextControl* redInput = (BTextControl*)fColorControl->ChildAt(0); BTextControl* greenInput = (BTextControl*)fColorControl->ChildAt(1); BTextControl* blueInput = (BTextControl*)fColorControl->ChildAt(2); redInput->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); greenInput->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); blueInput->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); }
AppearancePrefView::AppearancePrefView(const char* name, const BMessenger& messenger) : BGroupView(name, B_VERTICAL, 5), fTerminalMessenger(messenger) { const char* kColorTable[] = { B_TRANSLATE_MARK("Text"), B_TRANSLATE_MARK("Background"), B_TRANSLATE_MARK("Cursor"), B_TRANSLATE_MARK("Text under cursor"), B_TRANSLATE_MARK("Selected text"), B_TRANSLATE_MARK("Selected background"), NULL }; fBlinkCursor = new BCheckBox( B_TRANSLATE("Blinking cursor"), new BMessage(MSG_BLINK_CURSOR_CHANGED)); fBrightInsteadOfBold = new BCheckBox( B_TRANSLATE("Use bright instead of bold text"), new BMessage(MSG_BRIGHT_INSTEAD_OF_BOLD_CHANGED)); fWarnOnExit = new BCheckBox( B_TRANSLATE("Confirm exit if active programs exist"), new BMessage(MSG_WARN_ON_EXIT_CHANGED)); BMenu* fontMenu = _MakeFontMenu(MSG_HALF_FONT_CHANGED, PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY), PrefHandler::Default()->getString(PREF_HALF_FONT_STYLE)); fFontField = new BMenuField(B_TRANSLATE("Font:"), fontMenu); BMenu* sizeMenu = new (std::nothrow) BPopUpMenu( B_TRANSLATE_COMMENT("Custom", "Window size")); if (sizeMenu != NULL) { TermWindow::MakeWindowSizeMenu(sizeMenu); sizeMenu->SetLabelFromMarked(true); } fWindowSizeField = new BMenuField(B_TRANSLATE("Window size:"), sizeMenu); BMenu* encodingMenu = new (std::nothrow) BPopUpMenu("Text encoding"); if (encodingMenu != NULL) { TermWindow::MakeEncodingMenu(encodingMenu); encodingMenu->SetLabelFromMarked(true); } fEncodingField = new BMenuField(B_TRANSLATE("Encoding:"), encodingMenu); BPopUpMenu* schemesPopUp = _MakeColorSchemeMenu(MSG_COLOR_SCHEME_CHANGED, gPredefinedColorSchemes, gPredefinedColorSchemes[0]); fColorSchemeField = new BMenuField(B_TRANSLATE("Color scheme:"), schemesPopUp); BPopUpMenu* colorsPopUp = _MakeMenu(MSG_COLOR_FIELD_CHANGED, kColorTable, kColorTable[0]); fColorField = new BMenuField(B_TRANSLATE("Color:"), colorsPopUp); fTabTitle = new BTextControl("tabTitle", B_TRANSLATE("Tab title:"), "", NULL); fTabTitle->SetModificationMessage( new BMessage(MSG_TAB_TITLE_SETTING_CHANGED)); fTabTitle->SetToolTip(BString(B_TRANSLATE( "The pattern specifying the tab titles. The following placeholders\n" "can be used:\n")) << kTooTipSetTabTitlePlaceholders); fWindowTitle = new BTextControl("windowTitle", B_TRANSLATE("Window title:"), "", NULL); fWindowTitle->SetModificationMessage( new BMessage(MSG_WINDOW_TITLE_SETTING_CHANGED)); fWindowTitle->SetToolTip(BString(B_TRANSLATE( "The pattern specifying the window titles. The following placeholders\n" "can be used:\n")) << kTooTipSetWindowTitlePlaceholders); BLayoutBuilder::Group<>(this) .SetInsets(5, 5, 5, 5) .AddGrid(5, 5) .Add(fTabTitle->CreateLabelLayoutItem(), 0, 0) .Add(fTabTitle->CreateTextViewLayoutItem(), 1, 0) .Add(fWindowTitle->CreateLabelLayoutItem(), 0, 1) .Add(fWindowTitle->CreateTextViewLayoutItem(), 1, 1) .Add(fWindowSizeField->CreateLabelLayoutItem(), 0, 2) .Add(fWindowSizeField->CreateMenuBarLayoutItem(), 1, 2) .Add(fFontField->CreateLabelLayoutItem(), 0, 3) .Add(fFontField->CreateMenuBarLayoutItem(), 1, 3) .Add(fEncodingField->CreateLabelLayoutItem(), 0, 4) .Add(fEncodingField->CreateMenuBarLayoutItem(), 1, 4) .Add(fColorSchemeField->CreateLabelLayoutItem(), 0, 5) .Add(fColorSchemeField->CreateMenuBarLayoutItem(), 1, 5) .Add(fColorField->CreateLabelLayoutItem(), 0, 6) .Add(fColorField->CreateMenuBarLayoutItem(), 1, 6) .End() .AddGlue() .Add(fColorControl = new BColorControl(BPoint(10, 10), B_CELLS_32x8, 8.0, "", new BMessage(MSG_COLOR_CHANGED))) .Add(fBlinkCursor) .Add(fBrightInsteadOfBold) .Add(fWarnOnExit); fTabTitle->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); fWindowTitle->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); fFontField->SetAlignment(B_ALIGN_RIGHT); fWindowSizeField->SetAlignment(B_ALIGN_RIGHT); fEncodingField->SetAlignment(B_ALIGN_RIGHT); fColorField->SetAlignment(B_ALIGN_RIGHT); fColorSchemeField->SetAlignment(B_ALIGN_RIGHT); Revert(); BTextControl* redInput = (BTextControl*)fColorControl->ChildAt(0); BTextControl* greenInput = (BTextControl*)fColorControl->ChildAt(1); BTextControl* blueInput = (BTextControl*)fColorControl->ChildAt(2); redInput->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); greenInput->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); blueInput->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); }