static ArpIntControl* new_component(BRect& f, float iw,
									const char* n, uint32 msg)
{
	f.left = f.right + 2;
	f.right = f.left + iw;
	ArpIntControl*	ic = new _ArpRgbaControl(f, n, NULL, new BMessage(msg));
	if (!ic) return 0;
	ic->SetLimits(0, 255);
	return ic;
}
void ArpKnobPanel::LayoutVertical(	const char* name, const char* label, BMessage* message,
									int32 minValue, int32 maxValue,
									bool showIntControl, uint32 knobFlags, float labelWidth,
									float intControlWidth)
{
	const BFont*	font = be_plain_font;
	float			fh = arp_get_font_height(font);
	float			spaceY = 3;
	float			top = 0;
	float			widest = 0;		// Cache the widest view just to save ourselves an
									// extra iteration over the views
	/* Add label
	 */
	BStringView*	sv = 0;
	if( label ) {
		float		w = (labelWidth >= 0) ? labelWidth : font->StringWidth( label );
		sv = new BStringView(	BRect( 0, top, 0 + w, top + fh ),
								"label", label );
		if( sv ) {
			AddChild( sv );
			if( w > widest ) widest = w;
		}
		top += fh + spaceY;
	}
	/* Add knob
	 */
	float			knobW, knobH;
	if( knobFlags&ARP_RING_ADORNMENT ) {
		knobW = Prefs().Size(KNOB_RING_X);
		knobH = Prefs().Size(KNOB_RING_Y);
	} else if( knobFlags&ARP_TIGHT_RING_ADORNMENT ) {
		knobW = Prefs().Size(KNOB_RING_TIGHT_X);
		knobH = Prefs().Size(KNOB_RING_TIGHT_Y);
	} else {
		knobW = Prefs().Size(KNOB_X);
		knobH = Prefs().Size(KNOB_Y);
	}
	ArpKnobControl* knob = new ArpKnobControl(	BRect(0, top, knobW, top + knobH ),
												name, message, minValue, maxValue, knobFlags);
	if( knob ) {
		AddChild( knob );
		if( knobW > widest ) widest = knobW;
		top += knobH + spaceY;
	}
	/* Add int control
	 */
	ArpIntControl*	intCtrl = 0;
	if( showIntControl ) {
		float		w = (intControlWidth >= 0) ? intControlWidth : knobW;
		intCtrl = new ArpIntControl( BRect(0, top, w, top + Prefs().Size(INT_CTRL_Y) ),
									"int_control", 0, 0);
		if( intCtrl ) {
			intCtrl->SetLimits( minValue, maxValue );
			if( knob ) knob->SetIntControl( intCtrl );
			AddChild( intCtrl );
			if( w > widest ) widest = w;
		}
	}
	/* Now center everything based on the widest view.
	 */
	if( !sv && !intCtrl ) return;
	if( widest <= 0 ) return;

	BView*	view;
	for( view = ChildAt(0); view; view = view->NextSibling() ) {
		BRect	f = view->Frame();
		if( f.Width() < widest )
			view->MoveTo( (widest - f.Width()) / 2, f.top );
	}		
}
void ArpKnobPanel::LayoutHorizontal(const char* name, const char* label, BMessage* message,
									int32 minValue, int32 maxValue,
									bool showIntControl, uint32 knobFlags, float labelWidth,
									float intControlWidth)
{
	const BFont*	font = be_plain_font;
	float			fh = arp_get_font_height(font);
	float			spaceX = 8;
	float			left = 0;
	/* Add label
	 */
	BStringView*	sv = 0;
	if( label ) {
		float		w = (labelWidth >= 0) ? labelWidth : font->StringWidth( label );
		sv = new BStringView(	BRect( left, 0, left + w, 0 + fh ),
								"label", label );
		if( sv ) AddChild( sv );
		left += w + spaceX;
	}
	/* Add knob
	 */
	float			knobW, knobH;
	if( knobFlags&ARP_RING_ADORNMENT ) {
		knobW = Prefs().Size(KNOB_RING_X);
		knobH = Prefs().Size(KNOB_RING_Y);
	} else if( knobFlags&ARP_TIGHT_RING_ADORNMENT ) {
		knobW = Prefs().Size(KNOB_RING_TIGHT_X);
		knobH = Prefs().Size(KNOB_RING_TIGHT_Y);
	} else {
		knobW = Prefs().Size(KNOB_X);
		knobH = Prefs().Size(KNOB_Y);
	}
	ArpKnobControl* knob = new ArpKnobControl(	BRect(left, 0, left + knobW, 0 + knobH ),
												name, message, minValue, maxValue, knobFlags);
	if( knob ) {
		AddChild( knob );
		left += knobW + spaceX;
	}
	/* Add int control
	 */
	ArpIntControl*	intCtrl = 0;
	if( showIntControl ) {
		float		w = (intControlWidth >= 0) ? intControlWidth : knobW;
		intCtrl = new ArpIntControl( BRect(left, 0, left + w, 0 + Prefs().Size(INT_CTRL_Y) ),
									"int_control", 0, 0);
		if( intCtrl ) {
			intCtrl->SetLimits( minValue, maxValue );
			if( knob ) knob->SetIntControl( intCtrl );
			AddChild( intCtrl );
		}
	}
	/* Now center everything based on the tallest view.
	 */
	if( !sv && !intCtrl ) return;
	float	tallest = (knobH > fh) ? knobH : fh;

	BView*	view;
	for( view = ChildAt(0); view; view = view->NextSibling() ) {
		BRect	f = view->Frame();
		if( f.Height() < tallest )
			view->MoveTo( f.left, (tallest - f.Height()) / 2 );
	}		
}