TEnclosuresView::TEnclosuresView(BRect rect, BRect wind_rect) : BView(rect, "m_enclosures", B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW), fFocus(false) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BFont font(be_plain_font); font.SetSize(font.Size() * kPlainFontSizeScale); SetFont(&font); fOffset = 12; BRect r; r.left = ENCLOSE_TEXT_H + font.StringWidth( TR("Attachments: ")) + 5; r.top = ENCLOSE_FIELD_V; r.right = wind_rect.right - wind_rect.left - B_V_SCROLL_BAR_WIDTH - 9; r.bottom = Frame().Height() - 8; fList = new TListView(r, this); fList->SetInvocationMessage(new BMessage(LIST_INVOKED)); BScrollView *scroll = new BScrollView("", fList, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, 0, false, true); AddChild(scroll); scroll->ScrollBar(B_VERTICAL)->SetRange(0, 0); }
/******************************************************* * Setup the main view. Add in all the niffty components * we have made and get things rolling *******************************************************/ PrefKeys::PrefKeys():BView("Prefs keys",0){ SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); // add the prefs list at the left list = new BOutlineListView("key list"); BScrollView *sv = new BScrollView("scroll", list, B_WILL_DRAW, false, true, B_PLAIN_BORDER); sv->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); sv->MakeFocus(false); BListItem *item = NULL; for (int32 i=0; i<KeyBind.CountBindings(); i++){ if (KeyBind.GetMessage(KeyBind.GetID(i)) == SPLITTER){ if (item) list->Collapse(item); list->AddItem(item = new KeyItem(Language.get(KeyBind.GetID(i)), 0, 0, 0, 0, -1)); }else{ list->AddUnder(new KeyItem(Language.get(KeyBind.GetID(i)), KeyBind.GetKey(KeyBind.GetID(i)), KeyBind.GetMod(KeyBind.GetID(i)), KeyBind.GetKeyAlt(KeyBind.GetID(i)), KeyBind.GetModAlt(KeyBind.GetID(i)), i), item); } } if (item) list->Collapse(item); m_index = -1; BLayoutBuilder::Group<>(this) .AddGroup(B_VERTICAL, B_USE_DEFAULT_SPACING) .SetInsets(B_USE_WINDOW_SPACING) .Add(sv); }
void HTextView::MakeFocus(bool focused) { BScrollView* scrollView = dynamic_cast<BScrollView*>(Parent()); if (scrollView) scrollView->SetBorderHighlighted(focused); if (focused) SelectAll(); BTextView::MakeFocus(focused); } /* HTextView::MakeFocus */
void MemoryView::MakeFocus(bool isFocused) { BScrollView* parent = dynamic_cast<BScrollView*>(Parent()); if (parent != NULL) parent->SetBorderHighlighted(isFocused); BView::MakeFocus(isFocused); }
/******************************************************* * Setup the main view. Add in all the niffty components * we have made and get things rolling *******************************************************/ KeymapView::KeymapView() : BView(BRect(0,0,300,100), "Prefs keys", B_FOLLOW_ALL, B_WILL_DRAW) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); // add the prefs list at the left list = new BOutlineListView("key list"); BScrollView *sv = new BScrollView("scroll", list, B_FOLLOW_ALL_SIDES, false, true, B_PLAIN_BORDER); sv->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); sv->MakeFocus(false); BObjectList<BListItem> items(false); for (int32 i=0; i<gKeyBind->CountKeys(); i++) { uint32 code = gKeyBind->GetCode(i); if (code == FABER_SPLITTER) continue; BListItem* item = items.ItemAt(items.CountItems()-1); if (code == FABER_ITEM_END || code == FABER_EOF) { //if (item != NULL) { list->Collapse(item); items.RemoveItemAt(items.CountItems()-1); //} continue; } if (code == FABER_ITEM_START) { BListItem* newItem = new KeyItem(gKeyBind->GetLabel(i), 0, 0, 0, 0, -1); if (items.CountItems() > 0) { list->AddUnder(newItem, item); } else { list->AddItem(newItem); } items.AddItem(newItem); } else if (item != NULL) { list->AddUnder(new KeyItem(gKeyBind->GetLabel(i), gKeyBind->GetKey(code), gKeyBind->GetMod(code), gKeyBind->GetKeyAlt(code), gKeyBind->GetModAlt(code), i), item); } } m_index = -1; BLayoutBuilder::Group<>(this, B_VERTICAL, 1) .Add(sv, 0) .End(); }
// Setup the main view. Add in all the niffty components // we have made and get things rolling KeymapView::KeymapView() : BView(BRect(0,0,300,100), "Prefs keys", B_FOLLOW_ALL, B_WILL_DRAW) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); // add the prefs list at the left fListView = new BOutlineListView("key list"); BScrollView* scrollView = new BScrollView("scroll", fListView, B_FOLLOW_ALL_SIDES, false, true, B_PLAIN_BORDER); scrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); scrollView->MakeFocus(false); BObjectList<BListItem> items(false); for (int32 i=0; i < FaberShortcut::CountKeys(); i++) { KeyBind* bind = FaberShortcut::KeyBindAt(i); if (bind->itemType == FABER_SPLITTER) continue; BListItem* item = items.ItemAt(items.CountItems()-1); if (item != NULL && (bind->itemType == FABER_ITEM_END || bind->itemType == FABER_EOF)) { fListView->Collapse(item); items.RemoveItemAt(items.CountItems()-1); continue; } if (bind->itemType == FABER_ITEM_START) { BListItem* newItem = new KeyItem(bind->label, 0, 0, -1); if (items.CountItems() > 0) fListView->AddUnder(newItem, item); else fListView->AddItem(newItem); items.AddItem(newItem); } else if (item != NULL) { fListView->AddUnder(new KeyItem(bind->label, bind->key, bind->mod, i), item); } } fIndex = -1; BLayoutBuilder::Group<>(this, B_VERTICAL, 1) .Add(scrollView, 0) .End(); }
BScrollView * DTextView::MakeScrollView(const char *name, bool horizontal, bool vertical) { if (Parent()) RemoveSelf(); BScrollView *sv = new BScrollView(name, this, ResizingMode(), 0, horizontal, vertical); sv->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); return sv; }
FreqWindow::FreqWindow(BPoint p) : BWindow(BRect(p.x,p.y,p.x,p.y),Language.get("FREQ_WINDOW"),B_FLOATING_WINDOW_LOOK,B_FLOATING_APP_WINDOW_FEEL, B_NOT_RESIZABLE|B_NOT_ZOOMABLE) { BRect r(0,0,180,180); ResizeTo(r.Width(), r.Height()); MoveBy(-r.Width()/2, -r.Height()/2); view = new BView(r, NULL, B_FOLLOW_ALL, B_WILL_DRAW); r.InsetBy(8,8); r.right = 70; r.top += 28; // space for the textbox list = new BListView(r,"Freq list"); BScrollView *sv = new BScrollView("scroll", list, B_FOLLOW_ALL_SIDES, B_WILL_DRAW, false, true, B_PLAIN_BORDER); sv->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); sv->MakeFocus(false); view->AddChild(sv); r.Set(4,8,85,28); text = new SpinControl(r, NULL, NULL, new BMessage(SET_TEXT), 4000, 96000, 44100, 500); view->AddChild(text); r = Bounds(); r.left = r.right - 85; r.top = r.bottom - 32; r.bottom -=8; r.right -= 8; view->AddChild(new BButton(r, NULL, Language.get("OK"), new BMessage(SET)) ); r.OffsetBy(0,-30); view->AddChild(new BButton(r, NULL, Language.get("CANCEL"), new BMessage(QUIT)) ); view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(view); BStringItem *it; list->AddItem(it = new BStringItem("96000")); list->AddItem(it = new BStringItem("64000")); list->AddItem(it = new BStringItem("48000")); list->AddItem(it = new BStringItem("44100")); list->AddItem(it = new BStringItem("32000")); list->AddItem(it = new BStringItem("22050")); list->AddItem(it = new BStringItem("16000")); list->AddItem(it = new BStringItem("12500")); list->AddItem(it = new BStringItem("11025")); list->AddItem(it = new BStringItem("8000")); list->SetSelectionMessage(new BMessage(SELECT)); list->SetInvocationMessage(new BMessage(SELECT)); SetList(); m_old = Pool.frequency; Run(); Show(); }
void TimeZoneView::_InitView() { fZoneList = new BOutlineListView("cityList", B_SINGLE_SELECTION_LIST); fZoneList->SetSelectionMessage(new BMessage(H_CITY_CHANGED)); fZoneList->SetInvocationMessage(new BMessage(H_SET_TIME_ZONE)); _BuildZoneMenu(); BScrollView* scrollList = new BScrollView("scrollList", fZoneList, B_FRAME_EVENTS | B_WILL_DRAW, false, true); scrollList->SetExplicitMinSize(BSize(200, 0)); fCurrent = new TTZDisplay("currentTime", B_TRANSLATE("Current time:")); fPreview = new TTZDisplay("previewTime", B_TRANSLATE("Preview time:")); fSetZone = new BButton("setTimeZone", B_TRANSLATE("Set time zone"), new BMessage(H_SET_TIME_ZONE)); fSetZone->SetEnabled(false); fSetZone->SetExplicitAlignment( BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM)); BStringView* text = new BStringView("clockSetTo", B_TRANSLATE("Hardware clock set to:")); fLocalTime = new BRadioButton("localTime", B_TRANSLATE("Local time (Windows compatible)"), new BMessage(kRTCUpdate)); fGmtTime = new BRadioButton("greenwichMeanTime", B_TRANSLATE("GMT (UNIX compatible)"), new BMessage(kRTCUpdate)); if (fUseGmtTime) fGmtTime->SetValue(B_CONTROL_ON); else fLocalTime->SetValue(B_CONTROL_ON); _ShowOrHidePreview(); fOldUseGmtTime = fUseGmtTime; const float kInset = be_control_look->DefaultItemSpacing(); BLayoutBuilder::Group<>(this) .Add(scrollList) .AddGroup(B_VERTICAL, kInset) .Add(text) .AddGroup(B_VERTICAL, kInset) .Add(fLocalTime) .Add(fGmtTime) .End() .AddGlue() .Add(fCurrent) .Add(fPreview) .Add(fSetZone) .End() .SetInsets(kInset, kInset, kInset, kInset); }
AddOnListInfo::AddOnListInfo(BRect frame,BView *mother) : BWindow(frame,"DontWorryWindow",B_BORDERED_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL,B_AVOID_FOCUS ), _motherMessenger(mother) { CPreferences prefs(PREF_FILE_NAME,PREF_PATH_NAME); BRect listRect = Bounds(); BScrollView *scrollinfo; BView *scrollHBar; float scrollHsize; _lastClass = NULL; _typeRequested = -1; // initialisees les images prefs.Load(); _classesBitmap = prefs.GetBitmap("classes"); _metodesBitmap = prefs.GetBitmap("metodes"); _variablesBitmap = prefs.GetBitmap("variables"); _privateBitmap = prefs.GetBitmap("private"); _protectedBitmap = prefs.GetBitmap("protected"); _virtualBitmap = prefs.GetBitmap("virtual"); listRect.right -= 15; listRect.bottom -=15; _listOfInfos = new AddOnListView(listRect); scrollinfo = new BScrollView("scroll-info",_listOfInfos,B_FOLLOW_ALL_SIDES,0,true,true); // deplace la scroll bar du bas scrollHBar = scrollinfo->FindView("_HSB_"); scrollHBar->ResizeBy(-70,0); scrollHBar->MoveBy(70,0); scrollHsize = (scrollHBar->Bounds()).Height()+1; listRect = scrollinfo->Bounds(); _progress = new AddOnProgressView(BRect(2,listRect.bottom-scrollHsize,70,listRect.bottom-1)); scrollinfo->AddChild(_progress); AddChild(scrollinfo); // place le focus sur la liste _listOfInfos->MakeFocus(true); // envoyer le pointer de la fenetre a la vue pour les deplacement BMessage moveMsg(MOVE_WINDOW_PTR); moveMsg.AddPointer(WINDOW_RESULT_PTR,this); _motherMessenger.SendMessage(&moveMsg); }
// Stuff we can only do when the main view is attached to a window void OutputFormatView::AttachedToWindow() { // Get the window and lock it the_window = Window(); the_window->Lock(); // Set some size limits on the window the_window->SetSizeLimits( 200.0, 32767.0, Bounds().Height() - scroll_view->Bounds().Height() + 50.0, 32767.0); // Set the target for messages sent to this view list_view->SetTarget(this); the_button->SetTarget(this); // Make the list view the keyboard focus list_view->MakeFocus(); // Select the first item in the list, // and make its config view show up if (list_view->CountItems() > 0) list_view->Select(0); else the_button->SetEnabled(false); // Unlock the window the_window->Unlock(); // Call the base class BView::AttachedToWindow(); }
void TSignatureView::AttachedToWindow() { BRect rect = Bounds(); float name_text_length = StringWidth(kNameText); float sig_text_length = StringWidth(kSigText); float divide_length; if (name_text_length > sig_text_length) divide_length = name_text_length; else divide_length = sig_text_length; rect.InsetBy(8,0); rect.top+= 8; fName = new TNameControl(rect, kNameText, new BMessage(NAME_FIELD)); AddChild(fName); fName->SetDivider(divide_length + 10); fName->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT); rect.OffsetBy(0,fName->Bounds().Height()+5); rect.bottom = rect.top + kSigHeight; rect.left = fName->TextView()->Frame().left; BRect text = rect; text.OffsetTo(10,0); fTextView = new TSigTextView(rect, text); BScrollView *scroller = new BScrollView("SigScroller", fTextView, B_FOLLOW_ALL, 0, false, true); AddChild(scroller); scroller->ResizeBy(-1 * scroller->ScrollBar(B_VERTICAL)->Frame().Width() - 9, 0); scroller->MoveBy(7,0); /* back up a bit to make room for the label */ rect = scroller->Frame(); BStringView *stringView = new BStringView(rect, "SigLabel", kSigText); AddChild(stringView); float tWidth, tHeight; stringView->GetPreferredSize(&tWidth, &tHeight); /* the 5 is for the spacer in the TextView */ rect.OffsetBy(-1 *(tWidth) - 5, 0); rect.right = rect.left + tWidth; rect.bottom = rect.top + tHeight; stringView->MoveTo(rect.LeftTop()); stringView->ResizeTo(rect.Width(), rect.Height()); /* Resize the View to the correct height */ scroller->SetResizingMode(B_FOLLOW_NONE); ResizeTo(Frame().Width(), scroller->Frame().bottom + 8); scroller->SetResizingMode(B_FOLLOW_ALL); }
void FindTextView::MakeFocus(bool state) { BTextView::MakeFocus(state); if (fScrollView != NULL) fScrollView->SetBorderHighlighted(state); }
void TabFilteringTextView::MakeFocus(bool focused) { BTextView::MakeFocus(focused); if (fScrollView) fScrollView->SetBorderHighlighted(focused); }
/* * BLSettingsBlockedView(BRect canvas); * */ BLSettingsBlockedView::BLSettingsBlockedView(BRect canvas, BLSettings* bls) : BView(canvas, "blockedview", B_FOLLOW_ALL_SIDES, B_WILL_DRAW), Settings(bls), FilePanel(NULL) { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); float Padding = 5.0; float ButtonHeight = 25.0; /* Calculate list view position */ BRect rectLVPos = BRect(canvas.left + Padding, canvas.top + Padding, canvas.right - (Padding + B_V_SCROLL_BAR_WIDTH + 3), canvas.bottom - (Padding + 3 + B_H_SCROLL_BAR_HEIGHT + 35)); /* Create and add listview and scrollview*/ ListView = new BListView(rectLVPos, "Blocked"); BScrollView* scrollview = new BScrollView("scroll_blocked", ListView, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_NO_BORDER, true, true); scrollview->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(scrollview); /* Calculate the size and position of the Add button */ BRect btnAddRect(Bounds().right - (Padding + 60), Bounds().bottom - (Padding + ButtonHeight + 3), scrollview->Bounds().right, Bounds().bottom - (Padding + 3)); /* Create and add the Add button */ btnAdd = new BButton(btnAddRect, "BeLoginSettings_AddButton", "Add", new BMessage(BL_ADD_ITEM)); btnAdd->MakeDefault(true); btnAdd->SetTarget(this); AddChild(btnAdd); /* Calculate the size and position of the Add button */ BRect TextControlRect(ListView->Bounds().left , Bounds().bottom - (Padding + ButtonHeight), Bounds().right - (Padding*2 + btnAdd->Bounds().Width()) , ListView->Bounds().bottom - Padding); /* Create and add the password Textcontrol */ txtSignature = new BTextControl(TextControlRect, "BeLoginView_signature", "", "", NULL); txtSignature->SetDivider(0.0); AddChild(txtSignature); /* Add blocked to list */ BLBlocked* blocked = Settings->GetBlocked(); for(int i=0;i<blocked->CountItems();i++) ListView->AddItem(new BStringItem((blocked->ItemAt(i))->String())); /* Set up messaging */ ListView->SetInvocationMessage(new BMessage(BL_REMOVE_ITEM)); ListView->SetTarget(this); txtSignature->SetText("application/"); }
BView * Create_TEdit(BRect rct,int type) { BView *bt; BScrollView *sc; MyContainLv *bt1; bool a = false,b = false; switch(type) { case 1: a = false; b =true; break; case 2: a = true; b = false; break; case 3: a = b = true; break; } BRect kt = BRect(4,4,rct.IntegerWidth() - 4 - ((b) ? 14 : 0),rct.IntegerHeight() - 4 - ((a) ? 14 : 0)); if (bt = new BTextView(kt,"",BRect(5,5,kt.Width()-5,kt.Height()-5),B_FOLLOW_NONE,B_WILL_DRAW)) { if (sc = new BScrollView("",bt,B_FOLLOW_ALL,0,a,b)) { if (a) { BScrollBar *xi; if (xi = sc->ScrollBar(B_HORIZONTAL)) { xi->SetRange(0,0); } } if (bt1 = new MyContainLv(rct)) { bt1->AddChild(sc); return(bt1); } } } return(NULL); }
// Private function to switch between follow bottom behaviour void OutputFormatView::MakeFollowBottom(bool flag) { scroll_view->SetResizingMode(B_FOLLOW_LEFT_RIGHT | (flag ? B_FOLLOW_TOP_BOTTOM : B_FOLLOW_TOP)); cancel_button->SetResizingMode(B_FOLLOW_RIGHT | (flag ? B_FOLLOW_BOTTOM : B_FOLLOW_TOP)); the_button->SetResizingMode(B_FOLLOW_RIGHT | (flag ? B_FOLLOW_BOTTOM : B_FOLLOW_TOP)); info_caption->SetResizingMode(B_FOLLOW_LEFT_RIGHT | (flag ? B_FOLLOW_BOTTOM : B_FOLLOW_TOP)); info_view->SetResizingMode(B_FOLLOW_LEFT_RIGHT | (flag ? B_FOLLOW_BOTTOM : B_FOLLOW_TOP)); if (config_caption) config_caption->SetResizingMode(B_FOLLOW_LEFT_RIGHT | (flag ? B_FOLLOW_BOTTOM : B_FOLLOW_TOP)); }
void InspectorWindow::_Init() { fLanguage = new CppLanguage(); fExpressionInfo = new ExpressionInfo(); fExpressionInfo->AddListener(this); BScrollView* scrollView; BMenu* hexMenu = new BMenu("Hex Mode"); BMessage* message = new BMessage(MSG_SET_HEX_MODE); message->AddInt32("mode", HexModeNone); BMenuItem* item = new BMenuItem("<None>", message, '0'); hexMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", HexMode8BitInt); item = new BMenuItem("8-bit integer", message, '1'); hexMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", HexMode16BitInt); item = new BMenuItem("16-bit integer", message, '2'); hexMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", HexMode32BitInt); item = new BMenuItem("32-bit integer", message, '3'); hexMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", HexMode64BitInt); item = new BMenuItem("64-bit integer", message, '4'); hexMenu->AddItem(item); BMenu* endianMenu = new BMenu("Endian Mode"); message = new BMessage(MSG_SET_ENDIAN_MODE); message->AddInt32("mode", EndianModeLittleEndian); item = new BMenuItem("Little Endian", message, 'L'); endianMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", EndianModeBigEndian); item = new BMenuItem("Big Endian", message, 'B'); endianMenu->AddItem(item); BMenu* textMenu = new BMenu("Text Mode"); message = new BMessage(MSG_SET_TEXT_MODE); message->AddInt32("mode", TextModeNone); item = new BMenuItem("<None>", message, 'N'); textMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", TextModeASCII); item = new BMenuItem("ASCII", message, 'A'); textMenu->AddItem(item); BLayoutBuilder::Group<>(this, B_VERTICAL) .SetInsets(B_USE_DEFAULT_SPACING) .AddGroup(B_HORIZONTAL) .Add(fAddressInput = new BTextControl("addrInput", "Target Address:", "", new BMessage(MSG_INSPECT_ADDRESS))) .Add(fPreviousBlockButton = new BButton("navPrevious", "<", new BMessage(MSG_NAVIGATE_PREVIOUS_BLOCK))) .Add(fNextBlockButton = new BButton("navNext", ">", new BMessage(MSG_NAVIGATE_NEXT_BLOCK))) .End() .AddGroup(B_HORIZONTAL) .Add(fHexMode = new BMenuField("hexMode", "Hex Mode:", hexMenu)) .AddGlue() .Add(fEndianMode = new BMenuField("endianMode", "Endian Mode:", endianMenu)) .AddGlue() .Add(fTextMode = new BMenuField("viewMode", "Text Mode:", textMenu)) .End() .Add(scrollView = new BScrollView("memory scroll", NULL, 0, false, true), 3.0f) .AddGroup(B_HORIZONTAL) .Add(fWritableBlockIndicator = new BStringView("writableIndicator", _GetCurrentWritableIndicator())) .AddGlue() .Add(fEditBlockButton = new BButton("editBlock", "Edit", new BMessage(MSG_EDIT_CURRENT_BLOCK))) .Add(fCommitBlockButton = new BButton("commitBlock", "Commit", new BMessage(MSG_COMMIT_MODIFIED_BLOCK))) .Add(fRevertBlockButton = new BButton("revertBlock", "Revert", new BMessage(MSG_REVERT_MODIFIED_BLOCK))) .End() .End(); fHexMode->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fEndianMode->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); fTextMode->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); int32 targetEndian = fTeam->GetArchitecture()->IsBigEndian() ? EndianModeBigEndian : EndianModeLittleEndian; scrollView->SetTarget(fMemoryView = MemoryView::Create(fTeam, this)); fAddressInput->SetTarget(this); fPreviousBlockButton->SetTarget(this); fNextBlockButton->SetTarget(this); fPreviousBlockButton->SetEnabled(false); fNextBlockButton->SetEnabled(false); fEditBlockButton->SetTarget(this); fCommitBlockButton->SetTarget(this); fRevertBlockButton->SetTarget(this); fEditBlockButton->SetEnabled(false); fCommitBlockButton->Hide(); fRevertBlockButton->Hide(); hexMenu->SetLabelFromMarked(true); hexMenu->SetTargetForItems(fMemoryView); endianMenu->SetLabelFromMarked(true); endianMenu->SetTargetForItems(fMemoryView); textMenu->SetLabelFromMarked(true); textMenu->SetTargetForItems(fMemoryView); // default to 8-bit format w/ text display hexMenu->ItemAt(1)->SetMarked(true); textMenu->ItemAt(1)->SetMarked(true); if (targetEndian == EndianModeBigEndian) endianMenu->ItemAt(1)->SetMarked(true); else endianMenu->ItemAt(0)->SetMarked(true); fAddressInput->TextView()->MakeFocus(true); AddShortcut(B_LEFT_ARROW, B_COMMAND_KEY, new BMessage( MSG_NAVIGATE_PREVIOUS_BLOCK)); AddShortcut(B_RIGHT_ARROW, B_COMMAND_KEY, new BMessage( MSG_NAVIGATE_NEXT_BLOCK)); }
void TeamWindow::_Init() { BScrollView* sourceScrollView; const float splitSpacing = 3.0f; BLayoutBuilder::Group<>(this, B_VERTICAL, 0.0f) .Add(fMenuBar = new BMenuBar("Menu")) .AddSplit(B_VERTICAL, splitSpacing) .GetSplitView(&fFunctionSplitView) .SetInsets(B_USE_SMALL_INSETS) .Add(fTabView = new BTabView("tab view"), 0.4f) .AddSplit(B_HORIZONTAL, splitSpacing) .GetSplitView(&fSourceSplitView) .AddGroup(B_VERTICAL, B_USE_SMALL_SPACING) .AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING) .Add(fRunButton = new BButton("Run")) .Add(fStepOverButton = new BButton("Step over")) .Add(fStepIntoButton = new BButton("Step into")) .Add(fStepOutButton = new BButton("Step out")) .AddGlue() .End() .Add(fSourcePathView = new BStringView( "source path", "Source path unavailable."), 4.0f) .Add(sourceScrollView = new BScrollView("source scroll", NULL, 0, true, true), splitSpacing) .End() .Add(fLocalsTabView = new BTabView("locals view")) .End() .AddSplit(B_VERTICAL, splitSpacing) .GetSplitView(&fConsoleSplitView) .SetInsets(0.0) .Add(fConsoleOutputView = ConsoleOutputView::Create()) .End() .End(); // add source view sourceScrollView->SetTarget(fSourceView = SourceView::Create(fTeam, this)); // add threads tab BSplitView* threadGroup = new BSplitView(B_HORIZONTAL, splitSpacing); threadGroup->SetName("Threads"); fTabView->AddTab(threadGroup); BLayoutBuilder::Split<>(threadGroup) .GetSplitView(&fThreadSplitView) .Add(fThreadListView = ThreadListView::Create(fTeam, this)) .Add(fStackTraceView = StackTraceView::Create(this)); // add images tab BSplitView* imagesGroup = new BSplitView(B_HORIZONTAL, splitSpacing); imagesGroup->SetName("Images"); fTabView->AddTab(imagesGroup); BLayoutBuilder::Split<>(imagesGroup) .GetSplitView(&fImageSplitView) .Add(fImageListView = ImageListView::Create(fTeam, this)) .Add(fImageFunctionsView = ImageFunctionsView::Create(this)); // add breakpoints tab BGroupView* breakpointsGroup = new BGroupView(B_HORIZONTAL, B_USE_SMALL_SPACING); breakpointsGroup->SetName("Breakpoints"); fTabView->AddTab(breakpointsGroup); BLayoutBuilder::Group<>(breakpointsGroup) // .SetInsets(0.0f) .Add(fBreakpointsView = BreakpointsView::Create(fTeam, this)); // add local variables tab BView* tab = fVariablesView = VariablesView::Create(this); fLocalsTabView->AddTab(tab); // add registers tab tab = fRegistersView = RegistersView::Create(fTeam->GetArchitecture()); fLocalsTabView->AddTab(tab); fRunButton->SetMessage(new BMessage(MSG_THREAD_RUN)); fStepOverButton->SetMessage(new BMessage(MSG_THREAD_STEP_OVER)); fStepIntoButton->SetMessage(new BMessage(MSG_THREAD_STEP_INTO)); fStepOutButton->SetMessage(new BMessage(MSG_THREAD_STEP_OUT)); fRunButton->SetTarget(this); fStepOverButton->SetTarget(this); fStepIntoButton->SetTarget(this); fStepOutButton->SetTarget(this); fSourcePathView->SetExplicitMinSize(BSize(100.0, B_SIZE_UNSET)); fSourcePathView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); BMessageFilter* filter = new(std::nothrow) PathViewMessageFilter( BMessenger(this)); if (filter != NULL) fSourcePathView->AddFilter(filter); // add menus and menu items BMenu* menu = new BMenu("Team"); fMenuBar->AddItem(menu); BMenuItem* item = new BMenuItem("Restart", new BMessage( MSG_TEAM_RESTART_REQUESTED), 'R', B_SHIFT_KEY); menu->AddItem(item); item->SetTarget(this); item = new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED), 'W'); menu->AddItem(item); item->SetTarget(this); menu = new BMenu("Edit"); fMenuBar->AddItem(menu); item = new BMenuItem("Copy", new BMessage(B_COPY), 'C'); menu->AddItem(item); item->SetTarget(this); item = new BMenuItem("Select all", new BMessage(B_SELECT_ALL), 'A'); menu->AddItem(item); item->SetTarget(this); menu = new BMenu("Tools"); fMenuBar->AddItem(menu); item = new BMenuItem("Save debug report", new BMessage(MSG_CHOOSE_DEBUG_REPORT_LOCATION)); menu->AddItem(item); item->SetTarget(this); item = new BMenuItem("Inspect memory", new BMessage(MSG_SHOW_INSPECTOR_WINDOW), 'I'); menu->AddItem(item); item->SetTarget(this); AutoLocker< ::Team> locker(fTeam); _UpdateRunButtons(); }
ExpanderWindow::ExpanderWindow(BRect frame, const entry_ref* ref, BMessage* settings) : BWindow(frame, B_TRANSLATE_SYSTEM_NAME("Expander"), B_TITLED_WINDOW, B_NORMAL_WINDOW_FEEL), fSourcePanel(NULL), fDestPanel(NULL), fSourceChanged(true), fListingThread(NULL), fListingStarted(false), fExpandingThread(NULL), fExpandingStarted(false), fSettings(*settings), fPreferences(NULL) { BGroupLayout* layout = new BGroupLayout(B_VERTICAL, 0); SetLayout(layout); _AddMenuBar(layout); fDestButton = new BButton(B_TRANSLATE("Destination"), new BMessage(MSG_DEST)); fSourceButton = new BButton(B_TRANSLATE("Source"), new BMessage(MSG_SOURCE)); fExpandButton = new BButton(B_TRANSLATE("Expand"), new BMessage(MSG_EXPAND)); BSize size = fDestButton->PreferredSize(); size.width = max_c(size.width, fSourceButton->PreferredSize().width); size.width = max_c(size.width, fExpandButton->PreferredSize().width); fDestButton->SetExplicitMaxSize(size); fSourceButton->SetExplicitMaxSize(size); fExpandButton->SetExplicitMaxSize(size); fListingText = new BTextView("listingText"); fListingText->SetText(""); fListingText->MakeEditable(false); fListingText->SetStylable(false); fListingText->SetWordWrap(false); BFont font = be_fixed_font; fListingText->SetFontAndColor(&font); BScrollView* scrollView = new BScrollView("", fListingText, B_INVALIDATE_AFTER_LAYOUT, true, true); BView* topView = layout->View(); const float spacing = be_control_look->DefaultItemSpacing(); topView->AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing) .AddGroup(B_HORIZONTAL, spacing) .AddGroup(B_VERTICAL, 5.0) .Add(fSourceButton) .Add(fDestButton) .Add(fExpandButton) .End() .AddGroup(B_VERTICAL, spacing) .Add(fSourceText = new BTextControl(NULL, NULL, new BMessage(MSG_SOURCETEXT))) .Add(fDestText = new BTextControl(NULL, NULL, new BMessage(MSG_DESTTEXT))) .AddGroup(B_HORIZONTAL, spacing) .Add(fShowContents = new BCheckBox( B_TRANSLATE("Show contents"), new BMessage(MSG_SHOWCONTENTS))) .Add(fStatusView = new BStringView(NULL, NULL)) .End() .End() .End() .Add(scrollView) .SetInsets(spacing, spacing, spacing, spacing) ); size = topView->PreferredSize(); fSizeLimit = size.Height() - scrollView->PreferredSize().height - spacing; ResizeTo(Bounds().Width(), fSizeLimit); SetSizeLimits(size.Width(), 32767.0f, fSizeLimit, fSizeLimit); SetZoomLimits(Bounds().Width(), fSizeLimit); fPreviousHeight = -1; Show(); }
ShortcutsWindow::ShortcutsWindow() : BWindow(BRect(0, 0, 0, 0), B_TRANSLATE_SYSTEM_NAME("Shortcuts"), B_TITLED_WINDOW, 0L), fSavePanel(NULL), fOpenPanel(NULL), fSelectPanel(NULL), fKeySetModified(false), fLastOpenWasAppend(false) { ShortcutsSpec::InitializeMetaMaps(); float spacing = be_control_look->DefaultItemSpacing(); BView* top = new BView(Bounds(), NULL, B_FOLLOW_ALL_SIDES, 0); top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(top); BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), "Menu Bar"); BMenu* fileMenu = new BMenu(B_TRANSLATE("File")); fileMenu->AddItem(new BMenuItem(B_TRANSLATE("Open KeySet" B_UTF8_ELLIPSIS), new BMessage(OPEN_KEYSET), 'O')); fileMenu->AddItem(new BMenuItem( B_TRANSLATE("Append KeySet" B_UTF8_ELLIPSIS), new BMessage(APPEND_KEYSET), 'A')); fileMenu->AddItem(new BMenuItem(B_TRANSLATE("Revert to saved"), new BMessage(REVERT_KEYSET), 'A')); fileMenu->AddItem(new BSeparatorItem); fileMenu->AddItem(new BMenuItem( B_TRANSLATE("Save KeySet as" B_UTF8_ELLIPSIS), new BMessage(SAVE_KEYSET_AS), 'S')); fileMenu->AddItem(new BSeparatorItem); fileMenu->AddItem(new BMenuItem(B_TRANSLATE("Quit"), new BMessage(B_QUIT_REQUESTED), 'Q')); menuBar->AddItem(fileMenu); top->AddChild(menuBar); BRect tableBounds = Bounds(); tableBounds.top = menuBar->Bounds().bottom + 1; tableBounds.right -= B_V_SCROLL_BAR_WIDTH; tableBounds.bottom -= B_H_SCROLL_BAR_HEIGHT; BScrollView* containerView; fColumnListView = new ColumnListView(tableBounds, &containerView, NULL, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE, B_SINGLE_SELECTION_LIST, true, true, true, B_NO_BORDER); fColumnListView->SetEditMessage(new BMessage(HOTKEY_ITEM_MODIFIED), BMessenger(this)); float minListWidth = 0; // A running total is kept as the columns are created. float cellWidth = be_plain_font->StringWidth("Either") + 20; // ShortcutsSpec does not seem to translate the string "Either". for (int i = 0; i < ShortcutsSpec::NUM_META_COLUMNS; i++) { const char* name = ShortcutsSpec::GetColumnName(i); float headerWidth = be_plain_font->StringWidth(name) + 20; float width = max_c(headerWidth, cellWidth); minListWidth += width + 1; fColumnListView->AddColumn( new CLVColumn(name, CreateMetaPopUp(i), width, CLV_SORT_KEYABLE)); } float keyCellWidth = be_plain_font->StringWidth("Caps Lock") + 20; fColumnListView->AddColumn(new CLVColumn(B_TRANSLATE("Key"), CreateKeysPopUp(), keyCellWidth, CLV_SORT_KEYABLE)); minListWidth += keyCellWidth + 1; BPopUpMenu* popup = new BPopUpMenu(NULL, false); popup->AddItem(new BMenuItem( B_TRANSLATE("(Choose application with file requester)"), NULL)); popup->AddItem(new BMenuItem( B_TRANSLATE("*InsertString \"Your Text Here\""), NULL)); popup->AddItem(new BMenuItem( B_TRANSLATE("*MoveMouse +20 +0"), NULL)); popup->AddItem(new BMenuItem(B_TRANSLATE("*MoveMouseTo 50% 50%"), NULL)); popup->AddItem(new BMenuItem(B_TRANSLATE("*MouseButton 1"), NULL)); popup->AddItem(new BMenuItem( B_TRANSLATE("*LaunchHandler text/html"), NULL)); popup->AddItem(new BMenuItem( B_TRANSLATE("*Multi \"*MoveMouseTo 100% 0\" \"*MouseButton 1\""), NULL)); popup->AddItem(new BMenuItem(B_TRANSLATE("*MouseDown"), NULL)); popup->AddItem(new BMenuItem(B_TRANSLATE("*MouseUp"), NULL)); popup->AddItem(new BMenuItem( B_TRANSLATE("*SendMessage application/x-vnd.Be-TRAK 'Tfnd'"), NULL)); popup->AddItem(new BMenuItem(B_TRANSLATE("*Beep"), NULL)); fColumnListView->AddColumn(new CLVColumn(B_TRANSLATE("Application"), popup, 323.0, CLV_SORT_KEYABLE)); minListWidth += 323.0 + 1; minListWidth += B_V_SCROLL_BAR_WIDTH; fColumnListView->SetSortFunction(ShortcutsSpec::MyCompare); top->AddChild(containerView); fColumnListView->SetSelectionMessage(new BMessage(HOTKEY_ITEM_SELECTED)); fColumnListView->SetTarget(this); fAddButton = new BButton(BRect(0, 0, 0, 0), "add", B_TRANSLATE("Add new shortcut"), new BMessage(ADD_HOTKEY_ITEM), B_FOLLOW_BOTTOM); fAddButton->ResizeToPreferred(); fAddButton->MoveBy(spacing, Bounds().bottom - fAddButton->Bounds().bottom - spacing); top->AddChild(fAddButton); fRemoveButton = new BButton(BRect(0, 0, 0, 0), "remove", B_TRANSLATE("Remove selected shortcut"), new BMessage(REMOVE_HOTKEY_ITEM), B_FOLLOW_BOTTOM); fRemoveButton->ResizeToPreferred(); fRemoveButton->MoveBy(fAddButton->Frame().right + spacing, Bounds().bottom - fRemoveButton->Bounds().bottom - spacing); top->AddChild(fRemoveButton); fRemoveButton->SetEnabled(false); fSaveButton = new BButton(BRect(0, 0, 0, 0), "save", B_TRANSLATE("Save & apply"), new BMessage(SAVE_KEYSET), B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT); fSaveButton->ResizeToPreferred(); fSaveButton->MoveBy(Bounds().right - fSaveButton->Bounds().right - spacing, Bounds().bottom - fSaveButton->Bounds().bottom - spacing); top->AddChild(fSaveButton); fSaveButton->SetEnabled(false); containerView->ResizeBy(0, -(fAddButton->Bounds().bottom + 2 * spacing + 2)); float minButtonBarWidth = fRemoveButton->Frame().right + fSaveButton->Bounds().right + 2 * spacing; float minWidth = max_c(minListWidth, minButtonBarWidth); float menuBarHeight = menuBar->Bounds().bottom; float buttonBarHeight = Bounds().bottom - containerView->Frame().bottom; float minHeight = menuBarHeight + 200 + buttonBarHeight; SetSizeLimits(minWidth, MAX_WIDTH, minHeight, MAX_HEIGHT); // SetSizeLimits() will resize the window to the minimum size. CenterOnScreen(); entry_ref windowSettingsRef; if (_GetWindowSettingsFile(&windowSettingsRef)) { // The window settings file is not accepted via B_REFS_RECEIVED; this // is a behind-the-scenes file that the user will never see or // interact with. BFile windowSettingsFile(&windowSettingsRef, B_READ_ONLY); BMessage loadMsg; if (loadMsg.Unflatten(&windowSettingsFile) == B_OK) _LoadWindowSettings(loadMsg); } entry_ref keySetRef; if (_GetSettingsFile(&keySetRef)) { BMessage msg(B_REFS_RECEIVED); msg.AddRef("refs", &keySetRef); msg.AddString("startupRef", "please"); PostMessage(&msg); // Tell ourselves to load this file if it exists. } Show(); }
ProjectSettingsWindow::ProjectSettingsWindow(BRect frame, Project* project) : BWindow(frame, TR("Project settings"), B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS), fProject(project), fDirty(false) { if (fProject == NULL) debugger("Bad project given to Project Settings window"); fRefFilter = new TypedRefFilter(NULL, B_DIRECTORY_NODE); BMessenger messenger(this); entry_ref projectFolderRef; BEntry(fProject->GetPath().GetFolder()).GetRef(&projectFolderRef); fFilePanel = new BFilePanel(B_OPEN_PANEL, &messenger, &projectFolderRef, B_DIRECTORY_NODE, true, new BMessage(M_ADD_PATH), fRefFilter); fAutolock = new BAutolock(fProject); AddCommonFilter(new EscapeCancelFilter()); fTargetText = new AutoTextControl("targetname", TR("Target name:"), fProject->GetTargetName(), new BMessage(M_TARGET_NAME_CHANGED)); BPopUpMenu* targetTypeMenu = new BPopUpMenu(TR("Target type")); targetTypeMenu->AddItem(new BMenuItem(TR("Application"), new BMessage(M_SET_TARGET_TYPE))); targetTypeMenu->AddItem(new BMenuItem(TR("Shared library"), new BMessage(M_SET_TARGET_TYPE))); targetTypeMenu->AddItem(new BMenuItem(TR("Static library"), new BMessage(M_SET_TARGET_TYPE))); targetTypeMenu->AddItem(new BMenuItem(TR("Device driver"), new BMessage(M_SET_TARGET_TYPE))); fTypeField = new BMenuField("type", TR("Target type:"), targetTypeMenu); SetToolTip(fTypeField, TR("The kind of program you want to build")); BMenuItem* item = targetTypeMenu->ItemAt(fProject->TargetType()); if (item != NULL) item->SetMarked(true); fIncludeList = new IncludeList(fProject->GetPath().GetFolder()); SetToolTip(fIncludeList, TR("The folders you want Paladin to search for header files")); BScrollView* includeScrollView = new BScrollView("includescrollview", fIncludeList, B_WILL_DRAW, true, true); includeScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); includeScrollView->SetExplicitMinSize( BSize(be_plain_font->StringWidth("M") * 34.0f, be_plain_font->StringWidth("M") * 12.0f)); for (int32 i = 0; i < fProject->CountLocalIncludes(); i++) { fIncludeList->AddItem(new BStringItem( fProject->LocalIncludeAt(i).Relative().String())); } float buttonWidth = be_plain_font->StringWidth("+") * 2.0f + 3.0f; BButton* addButton = new BButton("addbutton", TR("+"), new BMessage(M_SHOW_ADD_PATH)); addButton->SetExplicitSize(BSize(buttonWidth, buttonWidth)); addButton->SetToolTip(TR("Add a file to the include path list")); BButton* removeButton = new BButton("removebutton", TR("−"), new BMessage(M_REMOVE_PATH)); removeButton->SetExplicitSize(BSize(buttonWidth, buttonWidth)); removeButton->SetToolTip(TR("Remove the selected path")); // general tab fGeneralView = new BView(TR("General"), B_WILL_DRAW); fGeneralView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BLayoutBuilder::Group<>(fGeneralView, B_VERTICAL, 0) .AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING) .Add(fTargetText->CreateLabelLayoutItem(), 0, 0) .Add(fTargetText->CreateTextViewLayoutItem(), 1, 0) .Add(fTypeField->CreateLabelLayoutItem(), 0, 1) .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 1) .Add(fTypeField->CreateMenuBarLayoutItem()) .AddGlue() .End() .End() .AddStrut(B_USE_DEFAULT_SPACING) .AddGroup(B_VERTICAL, 2.0f) .Add(new BStringView("include paths", TR("Include paths:"))) .AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING) .Add(includeScrollView) .AddGroup(B_VERTICAL, B_USE_SMALL_SPACING) .Add(addButton) .Add(removeButton) .AddGlue() .End() .End() .End() .SetInsets(B_USE_DEFAULT_SPACING) .End(); BPopUpMenu* optimizationMenu = new BPopUpMenu(TR("Optimization")); optimizationMenu->AddItem(new BMenuItem(TR("None"), new BMessage(M_SET_OP_VALUE))); optimizationMenu->AddItem(new BMenuItem(TR("Some"), new BMessage(M_SET_OP_VALUE))); optimizationMenu->AddItem(new BMenuItem(TR("More"), new BMessage(M_SET_OP_VALUE))); optimizationMenu->AddItem(new BMenuItem(TR("Full"), new BMessage(M_SET_OP_VALUE))); fOpField = new BMenuField("optimize", TR("Optimize:"), optimizationMenu); SetToolTip(fOpField, TR("Compiler optimization level. " "Disabled when debugging info is checked.")); item = optimizationMenu->ItemAt(fProject->OpLevel()); if (item != NULL) item->SetMarked(true); fOpSizeBox = new BCheckBox("opsizebox", TR("Optimize for size over speed"), new BMessage(M_TOGGLE_OPSIZE)); if (fProject->OpForSize()) fOpSizeBox->SetValue(B_CONTROL_ON); if (fProject->Debug()) { fOpField->SetEnabled(false); fOpSizeBox->SetEnabled(false); } fDebugBox = new BCheckBox("debugbox", TR("Build debugging information"), new BMessage(M_TOGGLE_DEBUG)); SetToolTip(fDebugBox, TR("Check this if you want to use your program in a debugger " "during development. You'll want to rebuild your project " "after change this.")); if (fProject->Debug()) fDebugBox->SetValue(B_CONTROL_ON); fProfileBox = new BCheckBox("profilebox", TR("Build profiling information"), new BMessage(M_TOGGLE_PROFILE)); SetToolTip(fProfileBox, TR("Check this if you want to use your program " "with gprof or bprof for profiling.")); if (fProject->Profiling()) fProfileBox->SetValue(B_CONTROL_ON); fCompileText = new AutoTextControl("extracc", "Extra compiler options:", fProject->ExtraCompilerOptions(), new BMessage(M_CCOPTS_CHANGED)); SetToolTip(fCompileText, TR("Extra GCC flags you wish included when each file is compiled.")); fLinkText = new AutoTextControl("extrald" ,TR("Extra linker options:"), fProject->ExtraLinkerOptions(), new BMessage(M_LDOPTS_CHANGED)); SetToolTip(fLinkText, TR("Extra GCC linker flags you wish included when your project " "is linked.")); // build tab fBuildView = new BView("Build", B_WILL_DRAW); fBuildView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BLayoutBuilder::Group<>(fBuildView, B_VERTICAL) .AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING) .Add(fOpField->CreateLabelLayoutItem(), 0, 0) .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 0) .Add(fOpField->CreateMenuBarLayoutItem()) .AddGlue() .End() .AddGroup(B_VERTICAL, 0.0f, 1, 2) .Add(fOpSizeBox) .AddStrut(B_USE_SMALL_SPACING) .Add(fDebugBox) .Add(fProfileBox) .End() .End() .AddGlue() .AddGroup(B_VERTICAL, 0) .Add(fCompileText->CreateLabelLayoutItem()) .Add(fCompileText->CreateTextViewLayoutItem()) .End() .AddGroup(B_VERTICAL, 0) .Add(fLinkText->CreateLabelLayoutItem()) .Add(fLinkText->CreateTextViewLayoutItem()) .End() .SetInsets(B_USE_DEFAULT_SPACING) .End(); fTabView = new BTabView("tabview", B_WIDTH_FROM_LABEL); fTabView->SetBorder(B_NO_BORDER); fTabView->AddTab(fGeneralView); fTabView->AddTab(fBuildView); fTabView->Select(0L); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .AddStrut(B_USE_SMALL_SPACING) .Add(fTabView) .End(); targetTypeMenu->SetTargetForItems(this); optimizationMenu->SetTargetForItems(this); fIncludeList->Select(0); fTargetText->MakeFocus(true); }
void InspectorWindow::_Init() { BScrollView* scrollView; BMenu* hexMenu = new BMenu("Hex Mode"); BMessage* message = new BMessage(MSG_SET_HEX_MODE); message->AddInt32("mode", HexModeNone); BMenuItem* item = new BMenuItem("<None>", message, '0'); hexMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", HexMode8BitInt); item = new BMenuItem("8-bit integer", message, '1'); hexMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", HexMode16BitInt); item = new BMenuItem("16-bit integer", message, '2'); hexMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", HexMode32BitInt); item = new BMenuItem("32-bit integer", message, '3'); hexMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", HexMode64BitInt); item = new BMenuItem("64-bit integer", message, '4'); hexMenu->AddItem(item); BMenu* endianMenu = new BMenu("Endian Mode"); message = new BMessage(MSG_SET_ENDIAN_MODE); message->AddInt32("mode", EndianModeLittleEndian); item = new BMenuItem("Little Endian", message, 'L'); endianMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", EndianModeBigEndian); item = new BMenuItem("Big Endian", message, 'B'); endianMenu->AddItem(item); BMenu* textMenu = new BMenu("Text Mode"); message = new BMessage(MSG_SET_TEXT_MODE); message->AddInt32("mode", TextModeNone); item = new BMenuItem("<None>", message, 'N'); textMenu->AddItem(item); message = new BMessage(*message); message->ReplaceInt32("mode", TextModeASCII); item = new BMenuItem("ASCII", message, 'A'); textMenu->AddItem(item); BLayoutBuilder::Group<>(this, B_VERTICAL) .SetInsets(4.0f, 4.0f, 4.0f, 4.0f) .AddGroup(B_HORIZONTAL, 4.0f) .Add(fAddressInput = new BTextControl("addrInput", "Target Address:", "", new BMessage(MSG_INSPECT_ADDRESS))) .Add(fPreviousBlockButton = new BButton("navPrevious", "<", new BMessage(MSG_NAVIGATE_PREVIOUS_BLOCK))) .Add(fNextBlockButton = new BButton("navNext", ">", new BMessage(MSG_NAVIGATE_NEXT_BLOCK))) .End() .AddGroup(B_HORIZONTAL, 4.0f) .Add(fHexMode = new BMenuField("hexMode", "Hex Mode:", hexMenu)) .AddGlue() .Add(fEndianMode = new BMenuField("endianMode", "Endian Mode:", endianMenu)) .AddGlue() .Add(fTextMode = new BMenuField("viewMode", "Text Mode:", textMenu)) .End() .Add(scrollView = new BScrollView("memory scroll", NULL, 0, false, true), 3.0f) .End(); fHexMode->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fEndianMode->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fTextMode->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); int32 targetEndian = fTeam->GetArchitecture()->IsBigEndian() ? EndianModeBigEndian : EndianModeLittleEndian; scrollView->SetTarget(fMemoryView = MemoryView::Create(fTeam)); fAddressInput->SetTarget(this); fPreviousBlockButton->SetTarget(this); fNextBlockButton->SetTarget(this); fPreviousBlockButton->SetEnabled(false); fNextBlockButton->SetEnabled(false); hexMenu->SetLabelFromMarked(true); hexMenu->SetTargetForItems(fMemoryView); endianMenu->SetLabelFromMarked(true); endianMenu->SetTargetForItems(fMemoryView); textMenu->SetLabelFromMarked(true); textMenu->SetTargetForItems(fMemoryView); // default to 8-bit format w/ text display hexMenu->ItemAt(1)->SetMarked(true); textMenu->ItemAt(1)->SetMarked(true); if (targetEndian == EndianModeBigEndian) endianMenu->ItemAt(1)->SetMarked(true); else endianMenu->ItemAt(0)->SetMarked(true); fAddressInput->TextView()->MakeFocus(true); }
ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entry) : BWindow(BRect(0.0f, 0.0f, 250.0f, 340.0f).OffsetBySelf(position), "Application Type", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS), fChangedProperties(0) { // add the menu BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), NULL); AddChild(menuBar); BMenu* menu = new BMenu("File"); fSaveMenuItem = new BMenuItem("Save", new BMessage(kMsgSave), 'S'); fSaveMenuItem->SetEnabled(false); menu->AddItem(fSaveMenuItem); BMenuItem* item; menu->AddItem(item = new BMenuItem("Save into resource file" B_UTF8_ELLIPSIS, NULL)); item->SetEnabled(false); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED), 'W', B_COMMAND_KEY)); menuBar->AddItem(menu); // Top view and signature BRect rect = Bounds(); rect.top = menuBar->Bounds().Height() + 1.0f; BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW); topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(topView); rect = topView->Bounds().InsetByCopy(8.0f, 8.0f); fSignatureControl = new BTextControl(rect, "signature", "Signature:", NULL, new BMessage(kMsgSignatureChanged), B_FOLLOW_LEFT_RIGHT); fSignatureControl->SetModificationMessage( new BMessage(kMsgSignatureChanged)); fSignatureControl->SetDivider(fSignatureControl->StringWidth( fSignatureControl->Label()) + 4.0f); float width, height; fSignatureControl->GetPreferredSize(&width, &height); fSignatureControl->ResizeTo(rect.Width(), height); topView->AddChild(fSignatureControl); // 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 BFont font(be_bold_font); font_height fontHeight; font.GetHeight(&fontHeight); width = font.StringWidth("Icon") + 16.0f; if (width < B_LARGE_ICON + 16.0f) width = B_LARGE_ICON + 16.0f; rect.top = fSignatureControl->Frame().bottom + 4.0f; rect.bottom = rect.top + 100.0f; rect.right -= width + 8.0f; BBox* box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT); topView->AddChild(box); fFlagsCheckBox = new BCheckBox(rect, "flags", "Application flags", new BMessage(kMsgToggleAppFlags)); fFlagsCheckBox->SetValue(B_CONTROL_ON); fFlagsCheckBox->ResizeToPreferred(); box->SetLabel(fFlagsCheckBox); rect.top = fFlagsCheckBox->Bounds().Height() + 4.0f; fSingleLaunchButton = new BRadioButton(rect, "single", "Single launch", new BMessage(kMsgAppFlagsChanged)); fSingleLaunchButton->ResizeToPreferred(); box->AddChild(fSingleLaunchButton); rect.OffsetBy(0.0f, fSingleLaunchButton->Bounds().Height() + 0.0f); fMultipleLaunchButton = new BRadioButton(rect, "multiple", "Multiple launch", new BMessage(kMsgAppFlagsChanged)); fMultipleLaunchButton->ResizeToPreferred(); box->AddChild(fMultipleLaunchButton); rect.OffsetBy(0.0f, fSingleLaunchButton->Bounds().Height() + 0.0f); fExclusiveLaunchButton = new BRadioButton(rect, "exclusive", "Exclusive launch", new BMessage(kMsgAppFlagsChanged)); fExclusiveLaunchButton->ResizeToPreferred(); box->AddChild(fExclusiveLaunchButton); rect.top = fSingleLaunchButton->Frame().top; rect.left = fExclusiveLaunchButton->Frame().right + 4.0f; fArgsOnlyCheckBox = new BCheckBox(rect, "args only", "Args only", new BMessage(kMsgAppFlagsChanged)); fArgsOnlyCheckBox->ResizeToPreferred(); box->AddChild(fArgsOnlyCheckBox); rect.top += fArgsOnlyCheckBox->Bounds().Height(); fBackgroundAppCheckBox = new BCheckBox(rect, "background", "Background app", new BMessage(kMsgAppFlagsChanged)); fBackgroundAppCheckBox->ResizeToPreferred(); box->AddChild(fBackgroundAppCheckBox); box->ResizeTo(box->Bounds().Width(), fExclusiveLaunchButton->Frame().bottom + 8.0f); // "Icon" group rect = box->Frame(); #ifdef __ANTARES__ rect.top += box->TopBorderOffset(); #endif rect.left = rect.right + 8.0f; rect.right += width + 8.0f; float iconBoxWidth = rect.Width(); box = new BBox(rect, NULL, B_FOLLOW_RIGHT | B_FOLLOW_TOP); box->SetLabel("Icon"); #ifdef __ANTARES__ box->MoveBy(0.0f, -box->TopBorderOffset()); box->ResizeBy(0.0f, box->TopBorderOffset()); #endif topView->AddChild(box); rect = BRect(8.0f, 0.0f, 7.0f + B_LARGE_ICON, B_LARGE_ICON - 1.0f); #ifdef __ANTARES__ rect.OffsetBy(0.0f, (box->Bounds().Height() + box->TopBorderOffset() - rect.Height()) / 2.0f); #else rect.OffsetBy(0.0f, (box->Bounds().Height() - rect.Height()) / 2.0f); #endif if (rect.top < fontHeight.ascent + fontHeight.descent + 4.0f) rect.top = fontHeight.ascent + fontHeight.descent + 4.0f; fIconView = new IconView(rect, "icon"); fIconView->SetModificationMessage(new BMessage(kMsgIconChanged)); box->AddChild(fIconView); // "Supported Types" group rect.top = box->Frame().bottom + 8.0f; rect.bottom = rect.top + box->Bounds().Height(); rect.left = 8.0f; rect.right = Bounds().Width() - 8.0f; BBox* typeBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT); typeBox->SetLabel("Supported types"); topView->AddChild(typeBox); rect = typeBox->Bounds().InsetByCopy(8.0f, 6.0f); rect.top += ceilf(fontHeight.ascent); fAddTypeButton = new BButton(rect, "add type", "Add" B_UTF8_ELLIPSIS, new BMessage(kMsgAddType), B_FOLLOW_RIGHT); fAddTypeButton->ResizeToPreferred(); fAddTypeButton->MoveBy(rect.right - fAddTypeButton->Bounds().Width() - B_LARGE_ICON - 16.0f, 0.0f); typeBox->AddChild(fAddTypeButton); rect = fAddTypeButton->Frame(); rect.OffsetBy(0, rect.Height() + 4.0f); fRemoveTypeButton = new BButton(rect, "remove type", "Remove", new BMessage(kMsgRemoveType), B_FOLLOW_RIGHT); typeBox->AddChild(fRemoveTypeButton); rect.right = rect.left - 10.0f - B_V_SCROLL_BAR_WIDTH; rect.left = 10.0f; rect.top = 8.0f + ceilf(fontHeight.ascent); rect.bottom -= 2.0f; // take scrollview border into account fTypeListView = new SupportedTypeListView(rect, "type listview", B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL); fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected)); BScrollView* scrollView = new BScrollView("type scrollview", fTypeListView, B_FOLLOW_ALL, B_FRAME_EVENTS | B_WILL_DRAW, false, true); typeBox->ResizeTo(typeBox->Bounds().Width(), fRemoveTypeButton->Frame().bottom + 8.0f); typeBox->AddChild(scrollView); rect.left = fRemoveTypeButton->Frame().right + 8.0f; #ifdef __ANTARES__ rect.top = (box->Bounds().Height() + box->TopBorderOffset() - B_LARGE_ICON) / 2.0f; #else rect.top = (box->Bounds().Height() - B_LARGE_ICON) / 2.0f; #endif rect.right = rect.left + B_LARGE_ICON - 1.0f; rect.bottom = rect.top + B_LARGE_ICON - 1.0f; fTypeIconView = new IconView(rect, "type icon", B_FOLLOW_RIGHT | B_FOLLOW_TOP); fTypeIconView->SetModificationMessage(new BMessage(kMsgTypeIconsChanged)); typeBox->AddChild(fTypeIconView); // "Version Info" group rect.top = typeBox->Frame().bottom + 8.0f; rect.bottom = rect.top + typeBox->Bounds().Height(); rect.left = 8.0f; rect.right = Bounds().Width() - 8.0f; box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT); // the resizing mode will later also be set to B_FOLLOW_BOTTOM box->SetLabel("Version info"); topView->AddChild(box); BMenuField* menuField; #if 0 BPopUpMenu *popUpMenu = new BPopUpMenu("version info", true, true); item = new BMenuItem("Version Info", NULL); item->SetMarked(true); popUpMenu->AddItem(item); item = new BMenuItem("System Version Info", NULL); popUpMenu->AddItem(item); menuField = new BMenuField(BRect(0, 0, 100, 15), "version kind", NULL, popUpMenu, true); menuField->ResizeToPreferred(); box->SetLabel(menuField); #endif rect.top = 4.0f + ceilf(fontHeight.ascent + fontHeight.descent); rect.bottom = rect.top + height; fMajorVersionControl = new BTextControl(rect, "major", "Version:", NULL, NULL); fMajorVersionControl->SetDivider(fMajorVersionControl->StringWidth( fMajorVersionControl->Label()) + 4.0f); fMajorVersionControl->GetPreferredSize(&width, &height); width = 12.0f + fMajorVersionControl->StringWidth("99"); fMajorVersionControl->ResizeTo(fMajorVersionControl->Divider() + width, height); _MakeNumberTextControl(fMajorVersionControl); box->AddChild(fMajorVersionControl); rect.left = fMajorVersionControl->Frame().right + 1.0f; fMiddleVersionControl = new BTextControl(rect, "middle", ".", NULL, NULL); fMiddleVersionControl->SetDivider(fMiddleVersionControl->StringWidth( fMiddleVersionControl->Label()) + 4.0f); fMiddleVersionControl->ResizeTo(fMiddleVersionControl->Divider() + width, height); _MakeNumberTextControl(fMiddleVersionControl); box->AddChild(fMiddleVersionControl); rect.left = fMiddleVersionControl->Frame().right + 1.0f; fMinorVersionControl = new BTextControl(rect, "middle", ".", NULL, NULL); fMinorVersionControl->SetDivider(fMinorVersionControl->StringWidth( fMinorVersionControl->Label()) + 4.0f); fMinorVersionControl->ResizeTo(fMinorVersionControl->Divider() + width, height); _MakeNumberTextControl(fMinorVersionControl); box->AddChild(fMinorVersionControl); fVarietyMenu = new BPopUpMenu("variety", true, true); fVarietyMenu->AddItem(new BMenuItem("Development", NULL)); fVarietyMenu->AddItem(new BMenuItem("Alpha", NULL)); fVarietyMenu->AddItem(new BMenuItem("Beta", NULL)); fVarietyMenu->AddItem(new BMenuItem("Gamma", NULL)); fVarietyMenu->AddItem(item = new BMenuItem("Golden master", NULL)); item->SetMarked(true); fVarietyMenu->AddItem(new BMenuItem("Final", NULL)); rect.top--; // BMenuField oddity rect.left = fMinorVersionControl->Frame().right + 6.0f; menuField = new BMenuField(rect, "variety", NULL, fVarietyMenu, true); menuField->ResizeToPreferred(); box->AddChild(menuField); rect.top++; rect.left = menuField->Frame().right; rect.right = rect.left + 30.0f; fInternalVersionControl = new BTextControl(rect, "internal", "/", NULL, NULL); fInternalVersionControl->SetDivider(fInternalVersionControl->StringWidth( fInternalVersionControl->Label()) + 4.0f); fInternalVersionControl->ResizeTo(fInternalVersionControl->Divider() + width, height); box->AddChild(fInternalVersionControl); rect = box->Bounds().InsetByCopy(8.0f, 0.0f); rect.top = fInternalVersionControl->Frame().bottom + 8.0f; fShortDescriptionControl = new BTextControl(rect, "short desc", "Short description:", NULL, NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); float labelWidth = fShortDescriptionControl->StringWidth( fShortDescriptionControl->Label()) + 4.0f; fShortDescriptionControl->SetDivider(labelWidth); fShortDescriptionControl->GetPreferredSize(&width, &height); fShortDescriptionControl->ResizeTo(rect.Width(), height); // 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)); box->AddChild(fShortDescriptionControl); rect.OffsetBy(0.0f, fShortDescriptionControl->Bounds().Height() + 5.0f); rect.right = rect.left + labelWidth; StringView* label = new StringView(rect, NULL, "Long description:", NULL); label->SetDivider(labelWidth); box->AddChild(label); rect.left = rect.right + 3.0f; rect.top += 1.0f; rect.right = box->Bounds().Width() - 10.0f - B_V_SCROLL_BAR_WIDTH; rect.bottom = rect.top + fShortDescriptionControl->Bounds().Height() * 3.0f - 1.0f; fLongDescriptionView = new TabFilteringTextView(rect, "long desc", rect.OffsetToCopy(B_ORIGIN), B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE); fLongDescriptionView->SetMaxBytes(sizeof(versionInfo.long_info)); scrollView = new BScrollView("desc scrollview", fLongDescriptionView, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_FRAME_EVENTS | B_WILL_DRAW, false, true); box->ResizeTo(box->Bounds().Width(), scrollView->Frame().bottom + 8.0f); box->AddChild(scrollView); // Adjust window size and limits width = fInternalVersionControl->Frame().right + 16.0f; float minWidth = fBackgroundAppCheckBox->Frame().right + iconBoxWidth + 32.0f; if (width > minWidth) minWidth = width; ResizeTo(Bounds().Width() > minWidth ? Bounds().Width() : minWidth, box->Frame().bottom + topView->Frame().top + 8.0f); SetSizeLimits(minWidth, 32767.0f, Bounds().Height(), 32767.0f); typeBox->SetResizingMode(B_FOLLOW_ALL); box->SetResizingMode(B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM); fSignatureControl->MakeFocus(true); BMimeType::StartWatching(this); _SetTo(entry); }
void PBox::AttachedToWindow(){ //calc font height (for nice control size) font_height fontHeight; be_bold_font->GetHeight(&fontHeight); fFontHeight = fontHeight.descent + fontHeight.leading + fontHeight.ascent; BRect frame = Bounds(); frame.InsetBy(5,5); BRect temp = frame; temp.bottom = temp.top + 40; SettingsTextView *testo1=new SettingsTextView(temp,"testo",_T("Settings")); AddChild(testo1); frame.top +=40; //BSeparator *sep=new BSeparator(frame,"sep","cippa"); //sep->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); //AddChild(sep); //frame.InsetBy(kEdgeOffset, kEdgeOffset); //frame.top += fFontHeight; //some space #if SCROLLBAR frame.right -= B_V_SCROLL_BAR_WIDTH + 2; #endif BView *view = new BView(frame, "", B_FOLLOW_ALL_SIDES,B_WILL_DRAW); #if B_BEOS_VERSION > B_BEOS_VERSION_5 view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); view->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); view->SetHighColor(ui_color(B_PANEL_TEXT_COLOR)); #else view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); view->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); view->SetHighColor(0, 0, 0, 0); #endif float settings_height = BuildGUI(fTemplate, fData, view); view->ResizeTo( view->Bounds().Width(), settings_height); #if SCROLLBAR BScrollView * scroller = new BScrollView( "scroller", view, B_FOLLOW_ALL, 0, false, true ); float scroll_height = scroller->Bounds().Height(); float diff = settings_height - scroll_height; if ( diff < 0 ) diff = 0; scroller->ScrollBar(B_VERTICAL)->SetRange(0, diff); view = scroller; #endif fPrefView = view; AddChild(fPrefView); testo1->SetText(fTemplate.FindString("name")); }
SCMImportWindow::SCMImportWindow(void) : DWindow(BRect(0,0,350,300), "Import from Repository") { MakeCenteredOnShow(true); BView *top = GetBackgroundView(); BMenu *menu = new BMenu("Providers"); for (int32 i = 0; i < fProviderMgr.CountImporters(); i++) { SCMProjectImporter *importer = fProviderMgr.ImporterAt(i); if (!importer) continue; BMessage *msg = new BMessage(M_USE_PROVIDER); menu->AddItem(new BMenuItem(importer->GetName(), msg)); } // Disable custom commands for now // menu->AddSeparatorItem(); // menu->AddItem(new BMenuItem("Custom", new BMessage(M_USE_CUSTOM_PROVIDER))); menu->SetLabelFromMarked(true); menu->ItemAt(0L)->SetMarked(true); BRect r(Bounds()); r.InsetBy(10.0, 10.0); r.bottom = 40.0; fProviderField = new BMenuField(r, "repofield", "Provider: ", menu, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); float pw, ph; fProviderField->GetPreferredSize(&pw, &ph); fProviderField->ResizeTo(r.Width(), ph); top->AddChild(fProviderField); r = fProviderField->Frame(); menu = new BMenu("Methods"); if (gHgAvailable) menu->AddItem(new BMenuItem("Mercurial", new BMessage(M_UPDATE_COMMAND))); if (gGitAvailable) menu->AddItem(new BMenuItem("Git", new BMessage(M_UPDATE_COMMAND))); if (gSvnAvailable) menu->AddItem(new BMenuItem("Subversion", new BMessage(M_UPDATE_COMMAND))); menu->SetLabelFromMarked(true); menu->ItemAt(0L)->SetMarked(true); fProvider = fProviderMgr.ImporterAt(0); r.OffsetBy(0.0, r.Height() + 10.0); fSCMField = new BMenuField(r, "scmfield", "Method: ", menu, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); top->AddChild(fSCMField); r.OffsetBy(0.0, r.Height() + 10.0); fProjectBox = new AutoTextControl(r, "project", "Project: ", "", new BMessage(M_UPDATE_COMMAND), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); fProjectBox->GetPreferredSize(&pw, &ph); fProjectBox->ResizeTo(r.Width(), ph); r = fProjectBox->Frame(); top->AddChild(fProjectBox); r.OffsetBy(0.0, r.Height() + 10.0); fAnonymousBox = new BCheckBox(r, "anonymous", "Anonymous check-out", new BMessage(M_TOGGLE_ANONYMOUS)); top->AddChild(fAnonymousBox); fAnonymousBox->ResizeToPreferred(); fAnonymousBox->SetValue(B_CONTROL_ON); r.OffsetBy(0.0, fAnonymousBox->Bounds().Height() + 10.0); fUserNameBox = new AutoTextControl(r, "username", "Username: "******"", new BMessage(M_UPDATE_COMMAND), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); top->AddChild(fUserNameBox); fUserNameBox->SetEnabled(false); r.OffsetBy(0.0, r.Height() + 10.0); fRepository = new AutoTextControl(r, "repository", "Repository (opt.): ", "", new BMessage(M_UPDATE_COMMAND), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); fRepository->GetPreferredSize(&pw, &ph); fRepository->ResizeTo(r.Width(), ph); r = fRepository->Frame(); top->AddChild(fRepository); r.OffsetBy(0.0, r.Height() + 10.0); fCommandLabel = new BStringView(r, "commandlabel", "Command: ", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); fCommandLabel->ResizeToPreferred(); top->AddChild(fCommandLabel); r.OffsetBy(0.0, fCommandLabel->Bounds().Height() + 5.0); r.bottom = r.top + 75.0; r.right -= B_V_SCROLL_BAR_WIDTH; BRect textRect = r.OffsetToCopy(0.0, 0.0).InsetByCopy(10.0, 10.0); fCommandView = new BTextView(r, "command", textRect, B_FOLLOW_ALL); BScrollView *scroll = new BScrollView("scrollview", fCommandView, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, 0, false, true); top->AddChild(scroll); fCommandView->MakeEditable(false); fOK = new BButton(r, "ok", "Import", new BMessage(M_SCM_IMPORT), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); fOK->ResizeToPreferred(); fOK->MoveTo(Bounds().right - 10.0 - fOK->Bounds().Width(), scroll->Frame().bottom + 10.0); ResizeTo(Bounds().Width(), fOK->Frame().bottom + 10.0); scroll->SetResizingMode(B_FOLLOW_ALL); top->AddChild(fOK); fOK->MakeDefault(true); fOK->SetEnabled(false); UpdateCommand(); fProviderField->MakeFocus(true); }
StartWindow::StartWindow(void) : DWindow(BRect(0,0,400,300),"Paladin",B_DOCUMENT_WINDOW, B_NOT_ZOOMABLE) { RegisterWindow(); AddShortcut('O',B_COMMAND_KEY, new BMessage(M_SHOW_OPEN_PROJECT)); AddShortcut('N',B_COMMAND_KEY, new BMessage(M_NEW_PROJECT)); AddShortcut('I',B_COMMAND_KEY, new BMessage(M_SHOW_IMPORT)); AddCommonFilter(new EscapeCancelFilter()); MakeCenteredOnShow(true); BView *top = GetBackgroundView(); fNewButton = MakeButton("new","NewProjectButtonUp.png","NewProjectButtonDown.png", M_NEW_PROJECT); top->AddChild(fNewButton); fNewButton->MoveTo(10,10); ClickableStringView *label = MakeLabel(fNewButton,TR("Create a new project")); top->AddChild(label); label->SetMessage(new BMessage(M_NEW_PROJECT)); fOpenButton = MakeButton("open","OpenProjectButtonUp.png", "OpenProjectButtonDown.png", M_SHOW_OPEN_PROJECT); top->AddChild(fOpenButton); fOpenButton->MoveTo(10,fNewButton->Frame().bottom + 10.0); label = MakeLabel(fOpenButton,"Open a project"); top->AddChild(label); label->SetMessage(new BMessage(M_SHOW_OPEN_PROJECT)); fOpenRecentButton = MakeButton("openrecent","OpenRecentButtonUp.png", "OpenRecentButtonDown.png", M_OPEN_SELECTION); top->AddChild(fOpenRecentButton); fOpenRecentButton->MoveTo(10,fOpenButton->Frame().bottom + 10.0); SetToolTip(fOpenRecentButton,TR("Open a project in the list on the right. You " "can also press Command + a number key.")); label = MakeLabel(fOpenRecentButton,TR("Open the selected project")); top->AddChild(label); label->SetMessage(new BMessage(M_OPEN_SELECTION)); BRect r(Bounds()); r.left = label->Frame().right + 20.0; r.right -= B_V_SCROLL_BAR_WIDTH + 10.0; r.top += 10.0; r.bottom -= 10.0; fListView = new StartWindowList(r); BScrollView *scrollView = new BScrollView("scroller",fListView,0, B_FOLLOW_ALL, false, true); top->AddChild(scrollView); fListView->SetInvocationMessage(new BMessage(M_OPEN_SELECTION)); SetToolTip(fListView, "Open a recent project. You can also press Command + a number key."); fQuickImportButton = MakeButton("quickimport","QuickImportButtonUp.png", "QuickImportButtonDown.png",M_SHOW_IMPORT); top->AddChild(fQuickImportButton); fQuickImportButton->MoveTo(10,fOpenRecentButton->Frame().bottom + 10.0); label = MakeLabel(fQuickImportButton,"Import an existing project"); top->AddChild(label); label->SetMessage(new BMessage(M_SHOW_IMPORT)); SetToolTip(label,TR("Quickly make a project by importing all source files and resource files.\n" "You can also import a BeIDE project.")); SetToolTip(fQuickImportButton, TR("Quickly make a project by importing all source files and resource files.\n" "You can also import a BeIDE project.")); fOnlineImportButton = MakeButton("onlineimport","OnlineImportButtonUp.png", "OnlineImportButtonDown.png",M_ONLINE_IMPORT); top->AddChild(fOnlineImportButton); fOnlineImportButton->MoveTo(10,fQuickImportButton->Frame().bottom + 10.0); label = MakeLabel(fOnlineImportButton,"Import a project from online"); top->AddChild(label); label->SetMessage(new BMessage(M_ONLINE_IMPORT)); SetToolTip(label,TR("Import a project from an online repository")); SetToolTip(fQuickImportButton, TR("Import a project from an online repository")); #ifdef DISABLE_ONLINE_IMPORT fOnlineImportButton->Hide(); SetSizeLimits(scrollView->Frame().left + 110.0,30000, fQuickImportButton->Frame().bottom + 10.0,30000); ResizeTo(scrollView->Frame().left + 160.0,fQuickImportButton->Frame().bottom + 10.0); #else SetSizeLimits(scrollView->Frame().left + 110.0,30000, fOnlineImportButton->Frame().bottom + 10.0,30000); ResizeTo(scrollView->Frame().left + 160.0,fOnlineImportButton->Frame().bottom + 10.0); #endif BMessenger msgr(this); BEntry entry(gProjectPath.GetFullPath()); entry_ref ref; entry.GetRef(&ref); fOpenPanel = new BFilePanel(B_OPEN_PANEL,&msgr,&ref,B_FILE_NODE,true, new BMessage(M_OPEN_PROJECT)); BString titleString(TR("Open Project")); titleString.Prepend("Paladin: "); fOpenPanel->Window()->SetTitle(titleString.String()); fImportPanel = new BFilePanel(B_OPEN_PANEL,&msgr,&ref,B_DIRECTORY_NODE,true, new BMessage(M_QUICK_IMPORT)); titleString = TR("Choose Project Folder"); titleString.Prepend("Paladin: "); fImportPanel->Window()->SetTitle(titleString.String()); gSettings.Lock(); int32 index = 0; while (gSettings.FindRef("recentitems",index++,&ref) == B_OK) { if (!BEntry(&ref).Exists()) { index--; gSettings.RemoveData("recentitems",index); } else fListView->AddItem(new RefStringItem(ref),0); } gSettings.Unlock(); // Alt + number opens that number project from the list int32 count = (fListView->CountItems() > 9) ? 9 : fListView->CountItems(); for (int32 i = 0; i < count; i++) { BMessage *listMsg = new BMessage(M_OPEN_FROM_LIST); listMsg->AddInt32("index", i); AddShortcut('1' + i, B_COMMAND_KEY, listMsg); } fNewButton->MakeFocus(true); }
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); }
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; }
RecipeEditor::RecipeEditor(const BRect &frame, const BMessenger &msgr, const int32 &number, const char *category) : BWindow(frame,"Add Recipe",B_FLOATING_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL, B_ASYNCHRONOUS_CONTROLS), fMessenger(msgr), fNumber(number), fCategory(category) { AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); AddShortcut('Q', B_COMMAND_KEY, new BMessage(M_QUIT_APP)); BView *back = new BView(Bounds(),"back",B_FOLLOW_ALL, B_WILL_DRAW); back->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); AddChild(back); fCategories = new BMenu("Categories"); CppSQLite3Query query = DBQuery("select category from categories order by category;", "RecipeEditor:get categories"); while(!query.eof()) { BString cat(DeescapeIllegalCharacters(query.getStringField(0))); BMessage *menumsg = new BMessage(M_CATEGORY_CHANGED); menumsg->AddString("name",cat); fCategories->AddItem(new BMenuItem(cat.String(),menumsg)); query.nextRow(); } fCategories->SetRadioMode(true); fCategories->SetLabelFromMarked(true); if(fCategories->CountItems()>0) fCategories->ItemAt(0)->SetMarked(true); BRect r(10,10,10 + fCategories->MaxContentWidth(),11); BMenuField *field = new BMenuField(r,"field","Category",fCategories, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP); back->AddChild(field); field->ResizeToPreferred(); r = field->Frame(); if(category) { BMenuItem *marked = fCategories->FindItem(category); if(marked) marked->SetMarked(true); } else { BMenuItem *marked = fCategories->ItemAt(0L); if(marked) marked->SetMarked(true); } r.OffsetBy(0,r.Height() + 10); fNameBox = new AutoTextControl(r,"namebox","Name: ",NULL,NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW | B_PULSE_NEEDED | B_NAVIGABLE | B_NAVIGABLE_JUMP); fNameBox->SetEscapeCancel(true); fNameBox->SetDivider(be_plain_font->StringWidth("Name ") + 5); back->AddChild(fNameBox); fNameBox->ResizeToPreferred(); r = fNameBox->Frame(); r.right = Bounds().right - 10; fNameBox->ResizeTo(r.Width(), r.Height()); r.OffsetBy(0,r.Height() + 10); BStringView *label = new BStringView(r,"inglabel","Ingredients:"); back->AddChild(label); r.OffsetBy(0,r.Height() + 10); r.bottom = r.top + 100; r.right -= B_V_SCROLL_BAR_WIDTH; BRect textrect = r.OffsetToCopy(0,0); textrect.InsetBy(10,10); fIngredientBox = new BTextView(r, "ingredients", textrect, B_FOLLOW_ALL, B_WILL_DRAW | B_PULSE_NEEDED | B_NAVIGABLE | B_NAVIGABLE_JUMP); fIngredientBox->SetDoesUndo(true); BScrollView *ingredscroll = new BScrollView("ingredients_scroller",fIngredientBox, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,0,false, true); back->AddChild(ingredscroll); r = ingredscroll->Frame(); label = new BStringView(BRect(10,10,11,11),"dirlabel","Directions:"); label->ResizeToPreferred(); label->MoveTo(10, r.bottom + 10); back->AddChild(label); r.OffsetBy(0,r.Height() + 20 + label->Frame().Height()); r.right -= B_V_SCROLL_BAR_WIDTH; textrect = r.OffsetToCopy(0,0); textrect.InsetBy(10,10); fDirectionsBox = new BTextView(r, "directions", textrect, B_FOLLOW_ALL, B_WILL_DRAW | B_PULSE_NEEDED | B_NAVIGABLE | B_NAVIGABLE_JUMP); fDirectionsBox->SetDoesUndo(true); BScrollView *dirscroll = new BScrollView("directions_scroller",fDirectionsBox, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,0,false, true); back->AddChild(dirscroll); fOK = new BButton(BRect(10,10,11,11),"ok","Cancel", new BMessage(M_ADD_RECIPE), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW); fOK->ResizeToPreferred(); fOK->SetLabel("OK"); fOK->MoveTo(Bounds().right - fOK->Bounds().Width() - 10, Bounds().bottom - fOK->Bounds().Height() - 10); r = fOK->Frame(); back->AddChild(fOK); r.OffsetBy(-r.Width() - 10, 0); fCancel = new BButton(r,"cancel","Cancel",new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW); back->AddChild(fCancel); field->MakeFocus(true); ResizeTo(Bounds().Width(), fDirectionsBox->Parent()->Frame().bottom + 20 + fOK->Bounds().Height()); dirscroll->SetResizingMode(B_FOLLOW_ALL); // This is the part that's different for editing a recipe as opposed to // just adding one to the database if(number >= 0 && category) { SetTitle("Edit Recipe"); BString name, ingredients, directions; if(GetRecipe(number,category,name,ingredients,directions)) { BMenuItem *item = fCategories->FindItem(category); if(item) item->SetMarked(true); fNameBox->SetText(name.String()); fIngredientBox->SetText(ingredients.String()); fDirectionsBox->SetText(directions.String()); fOK->SetMessage(new BMessage(M_EDIT_RECIPE)); } } AddShortcut(B_ENTER, B_COMMAND_KEY, new BMessage(fOK->Command())); }