void SplitWindow::AddCat() { ResizeBy(0, 25); uint16 xpos = 20; uint16 width = 150; BTextControl* tc = new BTextControl(BRect(xpos - 5, ypos + 10, xpos + width, ypos + 10), "CatField", "", "", 0); xpos += width; tc->SetDivider(0); catTexts.push_back(tc); v->AddChild(tc); BPopUpMenu* pu = new BPopUpMenu("", true, false); BMenuField* mf = new BMenuField(BRect(xpos + 2, ypos + 9, xpos + 2, ypos + 9), "CatMenu", "", pu); mf->SetDivider(0); v->AddChild(mf); xpos += 30; tc = new BTextControl(BRect(xpos - 5, ypos + 10, xpos + 75, ypos + 10), "AmountField", "", "", 0); tc->SetDivider(0); tc->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); tc->SetModificationMessage(new BMessage(AmountModifiedMSG)); amtTexts.push_back(tc); v->AddChild(tc); ypos += 25; for (cas::iterator ci = catS->begin(); ci != catS->end(); ci++) { if ((*ci)->IsRoot()) { pu->AddItem(MakeCatMenu(*ci)); } } catnum++; }
BView* PrefsWindow::constructGeneralBox(BRect frame) { BBox* generalBox = new BBox(frame); generalBox->SetLabel("General"); float offset = 30.0f, bwidth = 80.0f, bheight = 30.0f, bspacing = 10.0f, cbheight = 14.0f, adjust = 5.0f ; float controlX = (offset * 2.0f / 3.0f); BRect bubbleFrame = BRect(controlX, offset - adjust, offset + 150.0f, offset + cbheight - adjust); ColourButton *bubbleColourButton = new ColourButton(bubbleFrame, GetPrefsMessage(K_BUBBLE_COLOUR), ColourConstants::K_BLACK, "Tooltips"); generalBox->AddChild(bubbleColourButton); BRect recentDocsPathFrame(controlX, 50.0f, controlX + 150.0f, 70.0f); BCheckBox *showRecentDocsPath = new BCheckBox(recentDocsPathFrame, K_IS_RECENT_DOCS_SHOWN, "Show Path in Recent Docs", GetPrefsMessage(K_IS_RECENT_DOCS_SHOWN)); generalBox->AddChild(showRecentDocsPath); BRect isActivationFrame(controlX, 80.0f, controlX + 190.0f, 100.0f); BCheckBox *isActivationOk = new BCheckBox(isActivationFrame, K_IS_ACTIVATION_OK, "Activate Window on Opening Docs", GetPrefsMessage(K_IS_ACTIVATION_OK)); generalBox->AddChild(isActivationOk); BRect recentDocsFrame(controlX, 110.0f, controlX + 150.0f, 120.0f); BTextControl *numRecentDocs = new BTextControl(recentDocsFrame, K_NUM_RECENT_DOCS, "Number of Recent Docs", "", GetPrefsMessage(K_NUM_RECENT_DOCS)); numRecentDocs->SetDivider(120.0f); numRecentDocs->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); generalBox->AddChild(numRecentDocs); BRect insertDateFrame(controlX, 140.0f, controlX + 200.0f, 150.0f); BTextControl *insertDateFlags = new BTextControl(insertDateFrame, K_DATE_FLAGS, "Insert Date Flags", "", GetPrefsMessage(K_DATE_FLAGS)); generalBox->AddChild(insertDateFlags); BRect generalRect = generalBox->Bounds(); BRect generalbtnRect(generalRect.right - bspacing - bwidth, generalRect.bottom - bspacing - bheight, generalRect.right - bspacing, generalRect.bottom - bspacing); BButton *resetGeneralDefaults = new BButton(generalbtnRect,"fResetGeneralDefaults","Defaults",new BMessage(PrefsConstants::K_PREFS_VIEW_RESET_GENERAL_DEFAULTS)); generalBox->AddChild(resetGeneralDefaults); return generalBox; }
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) ); }
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); }