ArpTelnetSettings::ArpTelnetSettings( const BMessenger& telnet, const BMessage& initSettings, const BFont* font, uint32 resizingMode, uint32 flags) : ArpRootLayout(BRect(0,0,100,100), "Telnet", resizingMode, flags), mTelnet(telnet), mSettings(initSettings), mImpl(telnet, this, mSettings) { ArpD(cdb << ADH << "ArpTelnetSettings init vals: " << mSettings << endl); try { AddLayoutChild((new ArpRunningBar("TopHBar")) ->SetParams(ArpMessage() .SetInt32(ArpRunningBar::OrientationP, B_HORIZONTAL) .SetFloat(ArpRunningBar::IntraSpaceP, .5) ) ->AddLayoutChild((new ArpTextControl( ArpTelnet::HostConfigName,"Host:","", mImpl.AttachTextControl(ArpTelnet::HostConfigName))) ->SetParams(ArpMessage() .SetString(ArpTextControl::MinTextStringP, "WWWWWWW") .SetString(ArpTextControl::PrefTextStringP, "WWWWWWWWWWWWW") ) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest) ) ) ->AddLayoutChild((new ArpTextControl( ArpTelnet::PortConfigName,"Port:","23", mImpl.AttachTextControl(ArpTelnet::PortConfigName))) ->SetParams(ArpMessage() .SetString(ArpTextControl::MinTextStringP, "88") .SetString(ArpTextControl::PrefTextStringP, "88888") ) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,1) .SetInt32(ArpRunningBar::FillC,ArpEastWest) ) ) ); } catch(...) { throw; } mImpl.RefreshControls(mSettings); }
/***************************************************************************** * ARP-UNCERTAIN-CHORUS-SETTINGS *****************************************************************************/ ArpUncertainChorusSettings::ArpUncertainChorusSettings( AmFilterHolderI* target, const BMessage& initSettings) : inherited(target, initSettings) { float labelW = -1, intW = -1; const BFont* font = be_plain_font; if (font) { labelW = font->StringWidth("Frequency:") + 5; intW = font->StringWidth("Always") + 5; } try { ArpKnobPanel* freqPanel = NULL; AddLayoutChild((new ArpRunningBar("TopVBar")) ->SetParams(ArpMessage() .SetInt32(ArpRunningBar::OrientationP, B_VERTICAL) .SetFloat(ArpRunningBar::IntraSpaceP, .5) ) ->AddLayoutChild((new ArpTextControl( SZ_FILTER_LABEL, "Label:","", mImpl.AttachTextControl(SZ_FILTER_LABEL))) ->SetParams(ArpMessage() .SetString(ArpTextControl::MinTextStringP, "8") .SetString(ArpTextControl::PrefTextStringP, "8888888888") ) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest) ) ) ->AddLayoutChild((new ArpViewWrapper(freqPanel = new ArpKnobPanel(FREQUENCY_STR, "Frequency:", mImpl.AttachControl(FREQUENCY_STR), 0, 100, true, B_HORIZONTAL, ARP_TIGHT_RING_ADORNMENT, labelW, intW))) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest) ) ) ); if (freqPanel) { ArpIntControl* intCtrl = freqPanel->IntControl(); if (intCtrl) intCtrl->SetFormatter(arp_new_frequency_formatter() ); } } catch(...) { throw; } Implementation().RefreshControls(mSettings); }
void _RhythmiCcFilterSettings::AddViews(ArpBaseLayout* toLayout, ArpConfigureImpl& impl, float labelW, float intW, const BMessage& initSettings) { ArpBaseLayout* vBar = (new ArpRunningBar("SubVBar")) ->SetParams(ArpMessage() .SetInt32(ArpRunningBar::OrientationP, B_VERTICAL) .SetFloat(ArpRunningBar::IntraSpaceP, .5) ); toLayout->AddLayoutChild(vBar); vBar->AddLayoutChild((new AmControlChangeListPanel("Control Changes", this, initSettings)) ->SetParams(ArpMessage() .SetBool(ArpScrollArea::ScrollHorizontalP,false) .SetBool(ArpScrollArea::ScrollVerticalP,true) .SetBool(ArpScrollArea::InsetCornerP,false) .SetInt32(ArpScrollArea::BorderStyleP,B_FANCY_BORDER) ) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,1) .SetInt32(ArpRunningBar::FillC,ArpWest) .SetBool(ArpRunningBar::AlignLabelsC,false) ) ); ArpKnobPanel* kp = 0; vBar->AddLayoutChild((new ArpViewWrapper(kp = new ArpKnobPanel(PROXIMITY_STR, "Proximity to beat:", impl.AttachControl(PROXIMITY_STR), 0, 100, true, B_HORIZONTAL, ARP_TIGHT_RING_ADORNMENT, labelW, intW))) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest))); if (kp) { ArpIntControl* intCtrl = kp->IntControl(); if (intCtrl) intCtrl->SetFormatter( new _ProximityFormat() ); } vBar->AddLayoutChild((new ArpViewWrapper(kp = new ArpKnobPanel(FREQUENCY_STR, "Frequency:", impl.AttachControl(FREQUENCY_STR), 0, 100, true, B_HORIZONTAL, ARP_TIGHT_RING_ADORNMENT, labelW, intW))) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest))); if (kp) { ArpIntControl* intCtrl = kp->IntControl(); if (intCtrl) intCtrl->SetFormatter( new _FrequencyFormat() ); } vBar->AddLayoutChild((new ArpViewWrapper(kp = new ArpKnobPanel(AMOUNT_STR, "Amount:", impl.AttachControl(AMOUNT_STR), MIN_AMOUNT, MAX_AMOUNT, true, B_HORIZONTAL, ARP_TIGHT_RING_ADORNMENT, labelW, intW))) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest))); if (kp) { ArpIntControl* intCtrl = kp->IntControl(); if (intCtrl) intCtrl->SetFormatter( new _OffPercentFormat() ); } mRhythmField = new_rhythm_menu_field(); if (mRhythmField) { vBar->AddLayoutChild(mRhythmField ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest))); } }
_RhythmiCcFilterSettings::_RhythmiCcFilterSettings( AmFilterHolderI* target, const BMessage& initSettings) : AmFilterConfigLayout(target, initSettings), mRhythmField(NULL) { float labelW = -1, intW = -1; const BFont* font = be_plain_font; if( font ) { labelW = font->StringWidth( "Proximity to beat:"); intW = font->StringWidth("Furthest") + 5; } try { ArpBaseLayout* topVBar = (new ArpRunningBar("TopVBar")) ->SetParams(ArpMessage() .SetInt32(ArpRunningBar::OrientationP, B_VERTICAL) .SetFloat(ArpRunningBar::IntraSpaceP, .5) ); AddLayoutChild( topVBar ); topVBar->AddLayoutChild((new ArpTextControl( SZ_FILTER_LABEL, "Label:","", mImpl.AttachTextControl(SZ_FILTER_LABEL))) ->SetParams(ArpMessage() .SetString(ArpTextControl::MinTextStringP, "8") .SetString(ArpTextControl::PrefTextStringP, "8888888888") ) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest) ) ); ArpBaseLayout* colHBar = (new ArpRunningBar("ColHBar")) ->SetParams(ArpMessage() .SetInt32(ArpRunningBar::OrientationP, B_HORIZONTAL) .SetFloat(ArpRunningBar::IntraSpaceP, .5) ); topVBar->AddLayoutChild( colHBar ); AddViews(colHBar, mImpl, labelW, intW, initSettings); } catch(...) { throw; } Implementation().RefreshControls(mSettings); }
ArpAccentRandomizerFilterSettings( AmFilterHolderI* target, const BMessage& initSettings) : AmFilterConfigLayout(target, initSettings) { float labelW = -1; const BFont* font = be_plain_font; if (font) labelW = font->StringWidth("Randomize Amount:"); try { ArpKnobPanel* randomizePanel = NULL; AddLayoutChild((new ArpRunningBar("TopVBar")) ->SetParams(ArpMessage() .SetInt32(ArpRunningBar::OrientationP, B_VERTICAL) .SetFloat(ArpRunningBar::IntraSpaceP, .5) ) ->AddLayoutChild((new ArpTextControl( SZ_FILTER_LABEL, "Label:","", mImpl.AttachTextControl(SZ_FILTER_LABEL))) ->SetParams(ArpMessage() .SetString(ArpTextControl::MinTextStringP, "8") .SetString(ArpTextControl::PrefTextStringP, "8888888888") ) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest) ) ) ->AddLayoutChild((new ArpViewWrapper(randomizePanel = new ArpKnobPanel("randomize_amount", "Randomize Amount:", mImpl.AttachControl("randomize_amount"), 0, 25, true, B_HORIZONTAL, ARP_TIGHT_RING_ADORNMENT, labelW))) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC, 3) .SetInt32(ArpRunningBar::FillC, ArpEastWest) ) ) ); } catch(...) { throw; } Implementation().RefreshControls(mSettings); }
void TestWindow::MessageReceived(BMessage *message) { if( message ) { switch(message->what) { case TERM_SETTINGS_MSG: { if( !mTermWin.IsValid() ) { MakeTermSettings(); } } break; case ADD_TEST_MSG: { if( addpos && addpos->LayoutParent() ) { TestView* newView = new TestView("AddedTest"); newView->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,1) ); addpos->LayoutParent()->AddLayoutChild(newView, ArpNoParams, addpos); root->SetWindowLimits(); } } break; case REMOVE_TEST_MSG: { ArpBaseLayout* rempos = addpos ? addpos->PreviousLayoutSibling() : 0; if( rempos && rempos->LayoutName() ) { if( strcmp(rempos->LayoutName(), "AddedTest") == 0 ) { rempos->LayoutRemoveSelf(); delete rempos; root->SetWindowLimits(); } } } break; case ARP_PREF_MSG: { if( root ) root->UpdateGlobals(message); // Because we are just using a generic BWindow, the object // won't correctly handle changes to its global settings. //if( mTermSet.IsValid() ) mTermSet.SendMessage(message); } break; case PREFERENCES_MSG: { if( !mPrefWin.IsValid() ) { PrefWindow* pWindow = new PrefWindow(BMessenger(this),Globals()->GlobalValues()); if( pWindow ) { mPrefWin = pWindow; pWindow->Show(); } } } default: inherited::MessageReceived(message); } } }
static void add_vaccine_box(ArpBaseLayout* toLayout, ArpConfigureImpl& impl, float labelW, float intW) { ArpBaseLayout* vBar = (new ArpRunningBar("SubVBar")) ->SetParams(ArpMessage() .SetInt32(ArpRunningBar::OrientationP, B_VERTICAL) .SetFloat(ArpRunningBar::IntraSpaceP, .5) ); toLayout->AddLayoutChild(vBar); ArpKnobPanel* kp = 0; vBar->AddLayoutChild((new ArpViewWrapper(kp = new ArpKnobPanel(PROXIMITY_STR, "Proximity to beat:", impl.AttachControl(PROXIMITY_STR), 0, 100, true, B_HORIZONTAL, ARP_TIGHT_RING_ADORNMENT, labelW, intW))) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest))); if (kp) { ArpIntControl* intCtrl = kp->IntControl(); if (intCtrl) intCtrl->SetFormatter( new _ProximityFormat() ); } vBar->AddLayoutChild((new ArpViewWrapper(kp = new ArpKnobPanel(FREQUENCY_STR, "Frequency:", impl.AttachControl(FREQUENCY_STR), 0, 100, true, B_HORIZONTAL, ARP_TIGHT_RING_ADORNMENT, labelW, intW))) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest))); if (kp) { ArpIntControl* intCtrl = kp->IntControl(); if (intCtrl) intCtrl->SetFormatter( new _FrequencyFormat() ); } vBar->AddLayoutChild((new ArpViewWrapper(kp = new ArpKnobPanel(AMOUNT_STR, "Amount:", impl.AttachControl(AMOUNT_STR), MIN_AMOUNT, MAX_AMOUNT, true, B_HORIZONTAL, ARP_TIGHT_RING_ADORNMENT, labelW, intW))) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,3) .SetInt32(ArpRunningBar::FillC,ArpEastWest))); if (kp) { ArpIntControl* intCtrl = kp->IntControl(); if (intCtrl) intCtrl->SetFormatter( new _OffPercentFormat() ); } }
/***************************************************************************** * _CONTROLLER-RANGE-SETTINGS *****************************************************************************/ _ControllerRangeSettings::_ControllerRangeSettings( AmFilterHolderI* target, const BMessage& initSettings) : inherited(target, initSettings), mTable(0), mLowCtrl(0), mHighCtrl(0) { try { AddLayoutChild((new ArpRunningBar("TopVBar")) ->SetParams(ArpMessage() .SetInt32(ArpRunningBar::OrientationP, B_VERTICAL) .SetFloat(ArpRunningBar::IntraSpaceP, .5) ) ->AddLayoutChild((new ArpTextControl( SZ_FILTER_LABEL, "Label:","", mImpl.AttachTextControl(SZ_FILTER_LABEL))) ->SetParams(ArpMessage() .SetString(ArpTextControl::MinTextStringP, "8") .SetString(ArpTextControl::PrefTextStringP, "8888888888") ) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,0) .SetInt32(ArpRunningBar::FillC,ArpEastWest) .SetBool(ArpRunningBar::AlignLabelsC,false) ) ) ->AddLayoutChild((mTable = new _ArpControllerRangePanel("Control Changes", this, initSettings, _RANGE_MSG)) ->SetParams(ArpMessage() .SetBool(ArpScrollArea::ScrollHorizontalP,false) .SetBool(ArpScrollArea::ScrollVerticalP,true) .SetBool(ArpScrollArea::InsetCornerP,false) .SetInt32(ArpScrollArea::BorderStyleP,B_FANCY_BORDER) ) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,1) .SetInt32(ArpRunningBar::FillC,ArpWest) .SetBool(ArpRunningBar::AlignLabelsC,false) ) ) ->AddLayoutChild((mLowCtrl = new ArpIntControl( _LOW_VALUE, "Low value:", mImpl.AttachControl(_LOW_VALUE), 0, 127)) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,0) .SetInt32(ArpRunningBar::FillC,ArpEastWest) .SetBool(ArpRunningBar::AlignLabelsC,true) ) ) ->AddLayoutChild((mHighCtrl = new ArpIntControl( _HIGH_VALUE, "High value:", mImpl.AttachControl(_HIGH_VALUE), 0, 127)) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,0) .SetInt32(ArpRunningBar::FillC,ArpEastWest) .SetBool(ArpRunningBar::AlignLabelsC,true) ) ) ); } catch(...) { throw; } Implementation().RefreshControls(mSettings); }
ArpVelocityMapSettings(AmFilterHolderI* target, const BMessage& initSettings) : AmFilterConfigLayout(target, initSettings) { try { AddLayoutChild((new ArpRunningBar("TopVBar")) ->SetParams(ArpMessage() .SetInt32(ArpRunningBar::OrientationP, B_VERTICAL) .SetFloat(ArpRunningBar::IntraSpaceP, .5) ) ->AddLayoutChild((new ArpTextControl( SZ_FILTER_LABEL, "Label:","", mImpl.AttachTextControl(SZ_FILTER_LABEL))) ->SetParams(ArpMessage() .SetString(ArpTextControl::MinTextStringP, "8") .SetString(ArpTextControl::PrefTextStringP, "8888888888") ) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,0) .SetInt32(ArpRunningBar::FillC,ArpEastWest) .SetBool(ArpRunningBar::AlignLabelsC,false) ) ) ->AddLayoutChild((new ArpIntControl( FROM_MIN, "From start:", mImpl.AttachControl(FROM_MIN), 0, 127)) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,0) .SetInt32(ArpRunningBar::FillC,ArpEastWest) .SetBool(ArpRunningBar::AlignLabelsC,true) ) ) ->AddLayoutChild((new ArpIntControl( FROM_MAX, "From end:", mImpl.AttachControl(FROM_MAX), 0, 127)) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,0) .SetInt32(ArpRunningBar::FillC,ArpEastWest) .SetBool(ArpRunningBar::AlignLabelsC,true) ) ) ->AddLayoutChild((new ArpIntControl( TO_MIN, "To start:", mImpl.AttachControl(TO_MIN), 0, 127)) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,0) .SetInt32(ArpRunningBar::FillC,ArpEastWest) .SetBool(ArpRunningBar::AlignLabelsC,true) ) ) ->AddLayoutChild((new ArpIntControl( TO_MAX, "To end:", mImpl.AttachControl(TO_MAX), 0, 127)) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,0) .SetInt32(ArpRunningBar::FillC,ArpEastWest) .SetBool(ArpRunningBar::AlignLabelsC,true) ) ) ); } catch(...) { throw; } Implementation().RefreshControls(mSettings); }
TestWindow::TestWindow(BApplication* myApp) : BWindow(BRect(20,20,100,100), "ArpLayout Test", B_DOCUMENT_WINDOW, 0), root(0), addpos(0) { // NOTE!! // This is only one POSSIBLE way to create a layout hierarchy. // I use it because I happen to like it, but you don't need to. // You could also just create the objects individual and attach // them to each other as traditionally done with BViews; and // in the future, you will be able to flatten them into a BMessage // and reconstruct the layout hierarchy. // The layout engine also fully supports dynamically adding and // removing objects from an active hierarchy, so a tool for // creating control layouts should be possible to write. // Anyway... // First, create the window's UI layout. While doing so, // here are places to put some various UI objects that // we'll later want to manipulate outside of the layout // definition... ArpMenuBar* mainmenu = 0; ArpScrollArea* sarea = 0; ArpOutlineListView* mylist = 0; // Here is a standard set of parameters that we will apply to the // TestView class defined above. "SetIndirect" adds an "indirect" // parameter to the message -- it is really just a \0-terminated // string, but stored with a custom type. When the layout engine // sees this, it will retrieve the value for this parameter from // from the global name space; if that global parameter doesn't // exist, it is automatically created. Thus these two global // global parameters -- BoxBackColor and BoxTextColor -- will // automatically show up in the preferences view; changing them will // affect the BackgroundColor and ForegroundColor, respective, of // any views that use this association. ArpMessage box_params; box_params .SetIndirect("BackgroundColor","BoxBackColor") .SetIndirect("ForegroundColor","BoxTextColor"); // Another set of standard parameters that are applied to a // different TestView instance. FillBackColor and FillTextColor // are standard global values, which are the colors used to fill // data regions like list views and text areas. ArpMessage fill_params; fill_params .SetIndirect("BackgroundColor","FillBackColor") .SetIndirect("ForegroundColor","FillTextColor"); ArpD(cdb << ADH << "Initial Window Bounds: " << Bounds() << endl); // Now the layout definition itself: this supplies everything // needed to determine how to position and resize the UI. // Notice, not a single pixel in sight! // First, ArpRootLayout is the top of the layout hierarchy. It // is a BView and ArpLayoutable, which defines global information // about the interior layout: the layout conforms to the size of // this BView, and it contains the BMessage with the global // parameter set. // Note an import thing here: the layout does not care at all about // the surrounding window, so you can use the ArpLayoutable classes // to embed controls in a larger application that only knows about // raw BView objects. The ArpRootLayout class overrides its // GetPreferredSize() method to return the resulting information // about the underlying layout. (root = new ArpRootLayout(Bounds(), "Root")) // The first thing underneath the root object is an ArpRunningBar // with a vertical orientation. This positions its children one on // top of the other, the first one on top. ->AddLayoutChild((new ArpRunningBar("TopVBar")) // Set a parameter for the ArpRunningBar: its orientation should // be vertical. ->SetParams(ArpMessage() .SetInt32(ArpRunningBar::OrientationP, B_VERTICAL) ) // Add the first child to the running bar: this is the standard // menu structure at the top of the window. ->AddLayoutChild((mainmenu = new ArpMenuBar("MainMenu")) // Set the constraints for the menu bar. Constraints are like // parameters, except they are used by the parent widget to // determine how to layout its children; here, we say to set // its weight to zero, which tells the running bar that its // height (in the B_VERTICAL orientation) should not grow to // use any extra space. // // An ArpLayoutable object can contain any arbitrary constraints, // although only the ones its parent knows about will be used. ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,0) .SetInt32(ArpRunningBar::FillC,ArpFillAll) .SetBool(ArpRunningBar::AlignLabelsC,false) ) ) // Below the menu bar is an instance of our TestView BView. We set // its weight such that it will get some of any extra space that the // parent ArpRunningBar has. ->AddLayoutChild((new TestView("Test")) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,1) ) ) // Another child; here, just a raw ArpLayoutable, which will simply // result in a "gap" between the children before and after it. ->AddLayoutChild((new ArpLayout("Fill")) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,1) .SetInt32(ArpRunningBar::FillC,ArpFillAll) .SetBool(ArpRunningBar::AlignLabelsC,false) ) ) // The next child is another ArpRunningBar with a vertical orientation. ->AddLayoutChild((new ArpRunningBar("TestVBar")) ->SetParams(ArpMessage() .SetInt32(ArpRunningBar::OrientationP, B_VERTICAL) ) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,1) .SetInt32(ArpRunningBar::FillC,ArpFillAll) .SetBool(ArpRunningBar::AlignLabelsC,false) ) // Add the first child to this new running bar: another TestView. // Here we set the box_params parameters that we defined above, // giving it a custom coloring. ->AddLayoutChild((new TestView("Test1")) ->SetParams(box_params) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,1) ) ) // And now a horizontal running bar, which will place its children // across the bottom of the previous child. ->AddLayoutChild((new ArpRunningBar("TestHBar")) ->SetParams(ArpMessage() .SetInt32(ArpRunningBar::OrientationP, B_HORIZONTAL) ) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,1) ) // Plus three test views into this running bar. ->AddLayoutChild((new TestView("Test2")) ->SetParams(box_params) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,1) ) ) ->AddLayoutChild((new TestView("Test3")) ->SetParams(fill_params) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,1) ) ) ->AddLayoutChild((new TestView("Test4")) ->SetParams(box_params) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,1) ) ) ) ) // We're back up to the level of the first running bar. The // next child is a horizontal running bar, which contains the // three buttons. A new running bar constraint is used here, // "FillC", which controls how the object places its children // within their assigned space. Normally, if the maximum size // of a child is larger than the space assigned to it, it will // be made that maximum size and centered in the space. FillC // lets us do other things. ->AddLayoutChild((new ArpRunningBar("ButtonHBar")) ->SetParams(ArpMessage() .SetInt32(ArpRunningBar::OrientationP, B_HORIZONTAL) ) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,0) .SetInt32(ArpRunningBar::FillC,ArpFillAll) .SetBool(ArpRunningBar::AlignLabelsC,false) ) ->AddLayoutChild((new ArpButton("Terminal","Terminal" B_UTF8_ELLIPSIS, new BMessage(TERM_SETTINGS_MSG))) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,1) .SetInt32(ArpRunningBar::FillC,ArpCenter) ) ) ->AddLayoutChild((new ArpButton("Add","Add", new BMessage(ADD_TEST_MSG))) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,1) .SetInt32(ArpRunningBar::FillC,ArpCenter) ) ) ->AddLayoutChild((new ArpButton("Remove","Remove", new BMessage(REMOVE_TEST_MSG))) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,1) .SetInt32(ArpRunningBar::FillC,ArpCenter) ) ) ) // Finally, place the scrolling OutlineListView at the bottom // of the window. This is contained in a ArpScrollArea, which // is a custom implementation of BScrollArea the works better // with the layout system -- the BScrollArea doesn't report any // useful information about the dimensions of its children. ->AddLayoutChild((sarea = new ArpScrollArea("ScrollArea")) ->SetParams(ArpMessage() .SetBool(ArpScrollArea::ScrollHorizontalP,true) .SetBool(ArpScrollArea::ScrollVerticalP,true) .SetBool(ArpScrollArea::InsetCornerP,true) .SetInt32(ArpScrollArea::BorderStyleP,B_NO_BORDER) ) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,1) .SetInt32(ArpRunningBar::FillC,ArpFillAll) .SetBool(ArpRunningBar::AlignLabelsC,false) ) ->AddLayoutChild((mylist = new ArpOutlineListView( "MyList",B_SINGLE_SELECTION_LIST)) ->SetConstraints(ArpMessage() .SetFloat(ArpRunningBar::WeightC,1) ) ) ) ); // Find the position above which our buttons will add children. addpos = root->FindLayoutable("ButtonHBar"); // Place some items into the top menu bar. if( mainmenu ) { BMenu* first = new BMenu("File"); BMenuItem *item; item = new BMenuItem("About LayoutTest" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED)); item->SetTarget(myApp); first->AddItem(item); item = new BMenuItem("Preferences" B_UTF8_ELLIPSIS, new BMessage(PREFERENCES_MSG)); item->SetTarget(this); first->AddItem(item); item = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED)); item->SetTarget(myApp); first->AddItem(item); mainmenu->AddItem(first); mainmenu->SetFlags(mainmenu->Flags()|B_WILL_DRAW); } // Put some stuff into the list view. if( mylist ) { mylist->AddItem(new BStringItem("This is an example of the ArpLayout library.")); mylist->AddItem(new BStringItem("Play with the window; be sure to enlarge and shrink it!")); mylist->AddItem(new BStringItem("Other things to do:")); mylist->AddItem(new BStringItem("Another window")); mylist->AddItem(new BStringItem("Press the \"Terminal\" button to see a more",1)); mylist->AddItem(new BStringItem("complicated window.",1)); mylist->AddItem(new BStringItem("(No reward for guessing where it came from!",1)); mylist->AddItem(new BStringItem("Dynamic control")); mylist->AddItem(new BStringItem("Press the \"Add\" and \"Remove\" button to",1)); mylist->AddItem(new BStringItem("dynamically add and remove objects into the layout",1)); mylist->AddItem(new BStringItem("hierarchy.",1)); mylist->AddItem(new BStringItem("Parameters")); mylist->AddItem(new BStringItem("Select the \"Preferences\" menu item.",1)); mylist->AddItem(new BStringItem("This allows you to manipulate the global",1)); mylist->AddItem(new BStringItem("parameters of a layout, controlling font and",1)); mylist->AddItem(new BStringItem("color attributes. There are a number of",1)); mylist->AddItem(new BStringItem("standard global values, and others may be easily",1)); mylist->AddItem(new BStringItem("added by objects (such as the boxes, here) or",1)); mylist->AddItem(new BStringItem("as a layout is constructed.",1)); } // And finally attach the layout to the window, which will // compute the top-level dimensions. if( root ) { ArpD(cdb << ADH << "Before attach: win=" << Bounds() << ", root=" << root->Bounds() << endl); this->AddChild(root); ArpD(cdb << ADH << "After attach: win=" << Bounds() << ", root=" << root->Bounds() << endl); float w=100, h=00; root->GetPreferredSize(&w, &h); MoveTo(30,30); ResizeTo(w, h); ArpD(cdb << ADH << "After resize: win=" << Bounds() << ", root=" << root->Bounds() << endl); #if 0 printf("LAYOUT TREE:\n"); print_ltree(root,2); printf("VIEW TREE:\n"); print_vtree(root,2); #endif } }