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); }
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); }
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); }
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); }
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")); }
void TermWindow::_AddTab(Arguments* args, const BString& currentDirectory) { int argc = 0; const char* const* argv = NULL; if (args != NULL) args->GetShellArguments(argc, argv); ShellParameters shellParameters(argc, argv, currentDirectory); try { TermView* view = new TermView( PrefHandler::Default()->getInt32(PREF_ROWS), PrefHandler::Default()->getInt32(PREF_COLS), shellParameters, PrefHandler::Default()->getInt32(PREF_HISTORY_SIZE)); view->SetListener(this); TermViewContainerView* containerView = new TermViewContainerView(view); BScrollView* scrollView = new TermScrollView("scrollView", containerView, view, fSessions.IsEmpty()); if (!fFullScreen) scrollView->ScrollBar(B_VERTICAL) ->ResizeBy(0, -(B_H_SCROLL_BAR_HEIGHT - 1)); if (fSessions.IsEmpty()) fTabView->SetScrollView(scrollView); Session* session = new Session(_NewSessionID(), _NewSessionIndex(), containerView); fSessions.AddItem(session); BFont font; _GetPreferredFont(font); view->SetTermFont(&font); int width, height; view->GetFontSize(&width, &height); float minimumHeight = -1; if (fMenuBar != NULL) minimumHeight += fMenuBar->Bounds().Height() + 1; if (fTabView != NULL && fTabView->CountTabs() > 0) minimumHeight += fTabView->TabHeight() + 1; SetSizeLimits(MIN_COLS * width - 1, MAX_COLS * width - 1, minimumHeight + MIN_ROWS * height - 1, minimumHeight + MAX_ROWS * height - 1); // TODO: The size limit computation is apparently broken, since // the terminal can be resized smaller than MIN_ROWS/MIN_COLS! // If it's the first time we're called, setup the window if (fTabView != NULL && fTabView->CountTabs() == 0) { float viewWidth, viewHeight; containerView->GetPreferredSize(&viewWidth, &viewHeight); // Resize Window ResizeTo(viewWidth + B_V_SCROLL_BAR_WIDTH, viewHeight + fMenuBar->Bounds().Height() + 1); // NOTE: Width is one pixel too small, since the scroll view // is one pixel wider than its parent. } BTab* tab = new BTab; fTabView->AddTab(scrollView, tab); view->SetScrollBar(scrollView->ScrollBar(B_VERTICAL)); view->SetMouseClipboard(gMouseClipboard); const BCharacterSet* charset = BCharacterSetRoster::FindCharacterSetByName( PrefHandler::Default()->getString(PREF_TEXT_ENCODING)); if (charset != NULL) view->SetEncoding(charset->GetConversionID()); _SetTermColors(containerView); int32 tabIndex = fTabView->CountTabs() - 1; fTabView->Select(tabIndex); _UpdateSessionTitle(tabIndex); } catch (...) { // most probably out of memory. That's bad. // TODO: Should cleanup, I guess // Quit the application if we don't have a shell already if (fTabView->CountTabs() == 0) { fprintf(stderr, "Terminal couldn't open a shell\n"); PostMessage(B_QUIT_REQUESTED); } } }
int32 LibraryWindow::ScanThread(void *data) { LibraryWindow *win = (LibraryWindow *)data; float maxwidth; BRect r(5,5,105,20); BView *systemheader = win->AddHeader(r.LeftTop(),TR("System Libraries:")); win->Lock(); r = systemheader->Frame(); win->Unlock(); maxwidth = r.right; r.OffsetBy(0,r.Height() + 10); DPath sysPath = GetSystemPath(B_USER_DEVELOP_DIRECTORY); sysPath << "lib/x86"; BRect out = win->ScanFolder(r.LeftTop(),sysPath.GetFullPath(),&maxwidth); if (out != BRect(0,0,-1,-1)) { r = out; r.OffsetBy(0,10); } if (gPlatform == PLATFORM_HAIKU || gPlatform == PLATFORM_HAIKU_GCC4) { BView *commonheader = win->AddHeader(r.LeftTop(),TR("Common Libraries:")); win->Lock(); r = commonheader->Frame(); win->Unlock(); maxwidth = MAX(r.right,maxwidth); r.OffsetBy(0,r.Height() + 10); out = win->ScanFolder(r.LeftTop(),GetSystemPath(B_USER_LIB_DIRECTORY).GetFullPath(), &maxwidth); if (out != BRect(0,0,-1,-1)) { r = out; r.OffsetBy(0,10); } } BView *userheader = win->AddHeader(r.LeftTop(),TR("User Libraries:")); win->Lock(); r = userheader->Frame(); win->Unlock(); maxwidth = MAX(r.right,maxwidth); r.OffsetBy(0,r.Height() + 10); out = win->ScanFolder(r.LeftTop(),GetSystemPath(B_USER_LIB_DIRECTORY).GetFullPath(), &maxwidth); if (out.IsValid()) { r = out; r.OffsetBy(0,10); } win->Lock(); BView *top = win->GetBackgroundView(); BScrollView *scrollView = (BScrollView*)top->FindView("scrollView"); BScrollBar *vbar = scrollView->ScrollBar(B_VERTICAL); vbar->SetRange(0, r.bottom - scrollView->Bounds().Height()); vbar->SetSteps(r.Height() * 2.0,r.Height() * 8.0); gSettings.Lock(); BRect savedframe; if (gSettings.FindRect("libwin_frame",&savedframe) == B_OK) win->ResizeTo(savedframe.Width(),savedframe.Height()); gSettings.Unlock(); BStringView *label = (BStringView*)top->FindView("label"); label->SetText(TR("Choose the system libraries for your project.")); float minw = label->Frame().right + 10; win->SetSizeLimits(minw,30000,200,30000); if (win->Bounds().Width() < minw) win->ResizeTo(minw,win->Bounds().Height()); win->fScanThread = -1; win->Unlock(); return 0; }
ErrorWindow::ErrorWindow(BRect frame, ProjectWindow* parent, ErrorList* list) : BWindow(frame, B_TRANSLATE("Errors and warnings"), B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS), fParent(parent), fErrorCount(0), fWarningCount(0) { SetSizeLimits(400, 30000, 250, 30000); MoveTo(100,100); AddShortcut('M', B_COMMAND_KEY, new BMessage(M_MAKE_PROJECT)); AddShortcut('R', B_COMMAND_KEY, new BMessage(M_RUN_PROJECT)); AddShortcut('R', B_COMMAND_KEY | B_SHIFT_KEY, new BMessage(M_RUN_IN_TERMINAL)); AddShortcut('R', B_COMMAND_KEY | B_CONTROL_KEY, new BMessage(M_RUN_IN_DEBUGGER)); AddShortcut('R', B_COMMAND_KEY | B_CONTROL_KEY | B_SHIFT_KEY, new BMessage(M_RUN_WITH_ARGS)); AddShortcut('-', B_COMMAND_KEY, new BMessage(M_FORCE_REBUILD)); AddShortcut('I', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); if (list != NULL) fErrors = *list; if (parent != NULL) { BString text = B_TRANSLATE("Errors and warnings: "); text << fParent->GetProject()->GetName(); SetTitle(text.String()); } else debugger("BUG: Invalid project for error window"); BString startingLabel(B_TRANSLATE("Errors")); startingLabel << " (10000)"; fErrorBox = new BCheckBox("errorbox", startingLabel.String(), new BMessage(M_TOGGLE_ERRORS)); fErrorBox->SetLabel(B_TRANSLATE("Errors")); fErrorBox->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER)); startingLabel = B_TRANSLATE("Warnings"); startingLabel << " (10000)"; fWarningBox = new BCheckBox("warningbox", startingLabel.String(), new BMessage(M_TOGGLE_WARNINGS)); fWarningBox->SetLabel("Warnings"); fWarningBox->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER)); fCopyButton = new BButton("copy", B_TRANSLATE("Copy to clipboard"), new BMessage(M_COPY_ERRORS)); fErrorList = new DListView("errorlist", B_SINGLE_SELECTION_LIST, B_WILL_DRAW | B_NAVIGABLE); BScrollView* errorScrollView = fErrorList->MakeScrollView("scroller", true, true); errorScrollView->ScrollBar(B_HORIZONTAL)->SetSteps(25, 75); BPopUpMenu* contextMenu = new BPopUpMenu("context_menu", false, false); contextMenu->AddItem(new BMenuItem(B_TRANSLATE("Copy list to clipboard"), new BMessage(M_COPY_ERRORS))); contextMenu->SetTargetForItems(this); fErrorList->SetContextMenu(contextMenu); BView* header = BLayoutBuilder::Group<>(B_HORIZONTAL) .Add(fErrorBox) .Add(fWarningBox) .Add(fCopyButton) .AddGlue() .SetInsets(B_USE_DEFAULT_SPACING, 0, B_USE_DEFAULT_SPACING, 0) .View(); header->SetName("header"); header->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); BLayoutBuilder::Group<>(this, B_VERTICAL, 0) .Add(header) .Add(errorScrollView) .SetInsets(-1.0f) .End(); if (list != NULL) RefreshList(); BRect newframe; BNode node(fParent->GetProject()->GetPath().GetFullPath()); if (node.ReadAttr("error_frame", B_RECT_TYPE, 0, &newframe, sizeof(newframe))) { if (newframe.left < 100) newframe.left = 100; if (newframe.top < 100) newframe.top = 100; MoveTo(newframe.left, newframe.top); ResizeTo(newframe.Width(), newframe.Height()); } fErrorBox->SetValue(B_CONTROL_ON); fWarningBox->SetValue(B_CONTROL_ON); fErrorList->SetInvocationMessage(new BMessage(M_JUMP_TO_MSG)); fErrorList->MakeFocus(true); }
ProjectSettingsWindow::ProjectSettingsWindow(BRect frame, Project *proj) : DWindow(frame,TR("Project Settings"),B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_H_RESIZABLE), fProject(proj), fDirty(false) { if (!fProject) debugger("Bad project given to Project Settings window"); fRefFilter = new TypedRefFilter(NULL,B_DIRECTORY_NODE); BMessenger msgr(this); entry_ref projfolder_ref; BEntry(fProject->GetPath().GetFolder()).GetRef(&projfolder_ref); fFilePanel = new BFilePanel(B_OPEN_PANEL,&msgr,&projfolder_ref,B_DIRECTORY_NODE, true, new BMessage(M_ADD_PATH),fRefFilter); fAutolock = new BAutolock(fProject); AddCommonFilter(new EscapeCancelFilter()); BView *top = GetBackgroundView(); BRect r(Bounds()); fTabView = new BTabView(r,"tabview"); top->AddChild(fTabView); r.InsetBy(5,5); r.bottom -= fTabView->TabHeight(); BRect bounds = r.OffsetToCopy(0,0); fGeneralView = new BView(r,TR("General"),B_FOLLOW_ALL,B_WILL_DRAW); fGeneralView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fTabView->AddTab(fGeneralView); r.right -= 10.0; fTargetText = new AutoTextControl(r,"targetname",TR("Target Name:"), fProject->GetTargetName(), new BMessage(M_TARGET_NAME_CHANGED), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); fGeneralView->AddChild(fTargetText); float pwidth, pheight; fTargetText->GetPreferredSize(&pwidth, &pheight); fTargetText->ResizeTo(r.Width(),pheight); r.bottom = r.top + pheight; fTargetText->SetDivider(fTargetText->StringWidth(TR("Target Name:")) + 5.0); r = fTargetText->Frame(); r.OffsetBy(0,r.Height() + 10.0); BMenu *menu = new BMenu(TR("Target Type")); menu->AddItem(new BMenuItem(TR("Application"),new BMessage(M_SET_TARGET_TYPE))); menu->AddItem(new BMenuItem(TR("Shared Library"),new BMessage(M_SET_TARGET_TYPE))); menu->AddItem(new BMenuItem(TR("Static Library"),new BMessage(M_SET_TARGET_TYPE))); menu->AddItem(new BMenuItem(TR("Device Driver"),new BMessage(M_SET_TARGET_TYPE))); r.right = (bounds.right - 5.0) / 2.0; r.bottom = r.top + 25; fTypeField = new BMenuField(r,"type",TR("Target Type:"),menu); fGeneralView->AddChild(fTypeField); fTypeField->SetDivider(fTypeField->StringWidth(TR("Target Type:")) + 5.0); SetToolTip(fTypeField,TR("The kind of program you want to build")); menu->SetTargetForItems(this); menu->SetLabelFromMarked(true); BMenuItem *item = menu->ItemAt(fProject->TargetType()); if (item) item->SetMarked(true); r.OffsetBy(0,r.Height() + 10.0); BStringView *label = new BStringView(r,"label",TR("Include Paths:")); label->ResizeToPreferred(); fGeneralView->AddChild(label); r = label->Frame(); r.OffsetBy(0,r.Height() + 5.0); // We create a button now so that the list expands to fill the entire window // while leaving space for the two buttons at the bottom. Note that we do not // actually add the button to the window until later to preserve proper // keyboard navigation order BButton *add = new BButton(BRect(0,0,1,1),"addbutton",TR("Add…"), new BMessage(M_SHOW_ADD_PATH), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); add->ResizeToPreferred(); add->MoveTo(5,fGeneralView->Bounds().bottom - 10.0 - add->Frame().Height()); r.right = bounds.right - 10.0 - B_V_SCROLL_BAR_WIDTH; r.bottom = add->Frame().top - 10.0 - B_H_SCROLL_BAR_HEIGHT; fIncludeList = new IncludeList(r,fProject->GetPath().GetFolder()); BScrollView *scrollView = new BScrollView("scrollview",fIncludeList, B_FOLLOW_ALL,0, true, true); scrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fGeneralView->AddChild(scrollView); float width = 0.0; for (int32 i = 0; i < fProject->CountLocalIncludes(); i++) { BStringItem *item = new BStringItem(fProject->LocalIncludeAt(i).Relative().String()); float strwidth = fIncludeList->StringWidth(item->Text()); width = MAX(width, strwidth); fIncludeList->AddItem(item); } if (width > fIncludeList->Bounds().Width()) { BScrollBar *hbar = scrollView->ScrollBar(B_HORIZONTAL); hbar->SetRange(0.0, width - fIncludeList->Bounds().Width()); } SetToolTip(fIncludeList,TR("The folders you want Paladin to search for header files")); fGeneralView->AddChild(add); BButton *remove = new BButton(BRect(0,0,1,1),"removebutton",TR("Remove"), new BMessage(M_REMOVE_PATH), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); remove->ResizeToPreferred(); remove->MoveTo(add->Frame().right + 10.0, add->Frame().top); fGeneralView->AddChild(remove); r = bounds; fBuildView = new BView(bounds.OffsetByCopy(5,5),TR("Build"),B_FOLLOW_ALL,B_WILL_DRAW); fBuildView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fTabView->AddTab(fBuildView); menu = new BMenu(TR("Optimization")); menu->AddItem(new BMenuItem(TR("None"),new BMessage(M_SET_OP_VALUE))); menu->AddItem(new BMenuItem(TR("Some"),new BMessage(M_SET_OP_VALUE))); menu->AddItem(new BMenuItem(TR("More"),new BMessage(M_SET_OP_VALUE))); menu->AddItem(new BMenuItem(TR("Full"),new BMessage(M_SET_OP_VALUE))); r.right = (bounds.right - 5.0) / 2.0; r.bottom = r.top + 25; fOpField = new BMenuField(r,"optimize",TR("Optimize"),menu); fBuildView->AddChild(fOpField); fOpField->SetDivider(fOpField->StringWidth(TR("Optimize")) + 5.0); SetToolTip(fOpField,TR("Compiler optimization level. Disabled when debugging info is checked.")); menu->SetTargetForItems(this); menu->SetLabelFromMarked(true); item = menu->ItemAt(fProject->OpLevel()); if (item) item->SetMarked(true); r.right = bounds.right - 10.0; r.OffsetTo(5, fOpField->Frame().bottom + 5); fOpSizeBox = new BCheckBox(r,"opsizebox",TR("Optimize for size over speed"), new BMessage(M_TOGGLE_OPSIZE)); fOpSizeBox->ResizeToPreferred(); fBuildView->AddChild(fOpSizeBox); r = fOpSizeBox->Frame(); if (fProject->OpForSize()) fOpSizeBox->SetValue(B_CONTROL_ON); if (fProject->Debug()) { fOpField->SetEnabled(false); fOpSizeBox->SetEnabled(false); } r.OffsetBy(0, r.Height() + 10); fDebugBox = new BCheckBox(r,"debugbox",TR("Build debugging information"), new BMessage(M_TOGGLE_DEBUG)); fDebugBox->ResizeToPreferred(); if (fProject->Debug()) fDebugBox->SetValue(B_CONTROL_ON); fBuildView->AddChild(fDebugBox); 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.")); r.OffsetBy(0, r.Height()); fProfileBox = new BCheckBox(r,"profilebox",TR("Build profiling information"), new BMessage(M_TOGGLE_PROFILE)); fProfileBox->ResizeToPreferred(); if (fProject->Profiling()) fProfileBox->SetValue(B_CONTROL_ON); fBuildView->AddChild(fProfileBox); SetToolTip(fProfileBox,TR("Check this if you want to use your program " "with gprof or bprof for profiling.")); r.OffsetBy(0, r.Height() + 10.0); r.right = bounds.right - 10.0; fCompileText = new AutoTextControl(r,"extracc","Extra Compiler Options:", fProject->ExtraCompilerOptions(), new BMessage(M_CCOPTS_CHANGED), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); fBuildView->AddChild(fCompileText); fCompileText->SetDivider(fCompileText->StringWidth(fCompileText->Label()) + 5.0); SetToolTip(fCompileText,TR("Extra GCC flags you wish included when each file is compiled.")); r = fCompileText->Frame(); r.OffsetBy(0,r.Height() + 10); fLinkText = new AutoTextControl(r,"extrald",TR("Extra Linker Options:"), fProject->ExtraLinkerOptions(), new BMessage(M_LDOPTS_CHANGED), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); fBuildView->AddChild(fLinkText); fLinkText->SetDivider(fCompileText->Divider()); SetToolTip(fLinkText,TR("Extra GCC linker flags you wish included when your project is linked.")); fTabView->Select(0L); fBuildView->ResizeTo(fGeneralView->Bounds().Width(),fGeneralView->Bounds().Height()); fTargetText->MakeFocus(true); }