Beispiel #1
0
void ArpMenuBar::copy_font(BMenu* menu, BFont* font)
{
	if( !menu ) return;
	int32 num = menu->CountItems();
	for( int32 i=0; i<num; i++ ) {
		BMenu* child = menu->SubmenuAt(i);
		if( child ) {
			copy_font(child,font);
			child->SetFont(font);
			child->InvalidateLayout();
		}
	}
}
Beispiel #2
0
void ArpMenuField::copy_attrs(BMenu* menu)
{
	if( !menu ) return;
	int32 num = menu->CountItems();
	for( int32 i=0; i<num; i++ ) {
		BMenu* child = menu->SubmenuAt(i);
		if( child ) {
			copy_attrs(child);
			// the menu doesn't seem to see this.
			child->SetFont(&PV_MenuFont);
			child->SetHighColor(PV_MenuForeColor);
			child->SetLowColor(PV_MenuBackColor);
			child->SetViewColor(PV_MenuBackColor);
			child->InvalidateLayout();
		}
	}
}
Beispiel #3
0
void ArpMenuField::ComputeDimens(ArpDimens& cur_dimens)
{
	BMenu* menu = MenuBar();
	BMenu* popup = Menu();
	
	if( menu ) {
		copy_attrs(menu);
		copy_attrs(popup);
		menu->SetFont(&PV_MenuFont);
		menu->InvalidateLayout();
	}
	
	get_view_dimens(&cur_dimens, this, false);
	
	font_height fhs;
	BasicFont()->GetHeight(&fhs);
	const float fh = fhs.ascent+fhs.descent+fhs.leading;
	float fw = BasicFont()->StringWidth("WWWW");
	
	float pref_w=0;
	if( popup ) {
		int32 num = popup->CountItems();
		for( int32 i=0; i<num; i++ ) {
			BMenuItem* item = popup->ItemAt(i);
			if( item ) {
				const float w=BasicFont()->StringWidth(item->Label());
				ArpD(cdb << ADH << "Dimensions for popup label "
							<< item->Label() << ": " << w << endl);
				if( w > pref_w ) pref_w = w;
			}
		}
	}
	
	cur_dimens.Y().SetTo(0, fh+12, fh+12, fh+12, 0);
	
	float labelWidth = (Label() && *Label())
		? BasicFont()->StringWidth(Label())	+ BasicFont()->StringWidth(" ")
		: 0;
	
	cur_dimens.X().SetTo(labelWidth,
						 (fw < pref_w ? fw : pref_w) + 20,
						 pref_w + 20, pref_w + 20,
						 0);
}