// ------------------------------------------------------------------- // * Constructors & Destructor // ------------------------------------------------------------------- GDView::GDView(BRect frame, const char* title, uint32 mode, uint32 flags):BView(frame,title,mode,flags) { const float fView_ht = 20; // Add the display for the goodness of fit BRect fFrame(0,5,150,fView_ht); mFitView = new BStringView(fFrame,"Fit View",""); mFitView->SetFontSize(12); AddChild(mFitView); // Offset the frame to make room for the data display frame.OffsetTo(B_ORIGIN); BFont theFont; GetFont(&theFont); float width = theFont.StringWidth("Cubic Spline Fit "); frame.right -= width; frame.top += fView_ht; mGraph = new GDPolyPlot(&mData,frame); mGraph->SelectEnable(true); // Allow drag-rescaling mGraph->SetPlotMark(plotMark_plus); AddChild(mGraph); // Add the display for the parameters BRect dFrame(frame.right,0,Bounds().right,50); mDisp = new GDPolyDisp(&mData,dFrame); AddChild(mDisp); // Add the odometer mOdometer = new WGOdometer(mGraph); mOdometer->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); AddChild(mOdometer); mOdometer->ResizeToPreferred(); BRect oFrame = mOdometer->Bounds(); frame = Bounds(); // Get parent's size mOdometer->MoveTo(frame.right - oFrame.Width(),frame.bottom - oFrame.Height() - 15); // See what these do... // SetFontSize(12); // GetFont(&theFont); // mGraph->SetGraphFont(&theFont); // rgb_color red = {255,100,100,0}; // rgb_color black = {0,0,0,0}; // mGraph->SetGraphColor(red); }
string DialogFrame::showInputDialog(Component parentComponent, string option, string title, string message) { //parentComponent.drawWin(); string input; ConsoleWordWrapper::formatString(&message, 80); int dLength = getLengthFromString(message); int dWidth = getWidthFromString(message); int centerX = (parentComponent.getLength() / 2) - (dLength / 2); int centerY = (parentComponent.getWidth() / 2) - (dWidth / 2)-2; int startLine; Frame dFrame(centerX, centerY, dLength, dWidth+4, title); dFrame.setBackground(COLOR_WHITE); TextArea dTextArea = dFrame.addTextArea(); if (message.length() <= 80) { startLine = (dTextArea.getLength() / 2) - (message.length() / 2); } dTextArea.addText(startLine, 0, message); InputField dInputField(centerX + 5, dFrame.getBegY() + dFrame.getWidth()-6, dLength - 10, 3); //std::vector<std::string> bNames{ "Continue" }; dFrame.setSize(dFrame.getLength(), dFrame.getWidth() + 3); ButtonMenu dButtonMenu(dFrame.getBegX(), dFrame.getBegY() + dFrame.getWidth() - 4, dFrame.getLength(), 3, option); input = dInputField.getInput(); werase(dFrame.component); return input; }
void DialogFrame::showMessageDialog(Component parentComponent, string option, string title, string message) { //parentComponent.drawWin(); ConsoleWordWrapper::formatString(&message, 80); int dLength = getLengthFromString(message); int dWidth = getWidthFromString(message); int centerX = (parentComponent.getLength() / 2) - (dLength/2); int centerY = (parentComponent.getWidth() / 2) - (dWidth/2)-2; int startLine; Frame dFrame(centerX, centerY, dLength, dWidth, title); dFrame.setBackground(COLOR_WHITE); TextArea dTextArea = dFrame.addTextArea(); if (message.length() <= 80) { startLine = (dTextArea.getLength() / 2) - (message.length() / 2); } //startLine = 0; dTextArea.addText(startLine, 0, message); //Need to return the button menu itself from frame.h, but cant for some reason //dFrame.addButtonMenu("< Continue >"); //dFrame.setSize(dFrame.getLength(), dFrame.getWidth() + 4); dFrame.setSize(dFrame.getLength(), dFrame.getWidth() + 3); ButtonMenu dButtonMenu(dFrame.getBegX(), dFrame.getBegY() + dFrame.getWidth() - 4, dFrame.getLength(), 3, option); dButtonMenu.getButtonChoice(); werase(dFrame.component); }