Esempio n. 1
0
// MouseDown
void
OptionValueView::MouseDown(BPoint where)
{
	if (BView* parent = Parent())
		parent->MouseDown(ConvertToParent(where));
	
	if (fProperty) {
		BPopUpMenu* menu = new BPopUpMenu("option popup", false, false);
		BString name;
		int32 id;
		for (int32 i = 0; fProperty->GetOption(i, &name, &id); i++) {
			BMessage* message = new BMessage(MSG_OPTION_CHANGED);
			message->AddInt32("id", id);
			BMenuItem* item = new BMenuItem(name.String(), message);
			menu->AddItem(item);
			if (id == fProperty->CurrentOptionID())
				item->SetMarked(true);
		}
		menu->SetTargetForItems(this);
		menu->SetAsyncAutoDestruct(true);
		menu->SetFont(be_plain_font);
		menu->SetEnabled(fEnabled);

		where = ConvertToScreen(where);
		BRect mouseRect(where, where);
		mouseRect.InsetBy(-10.0, -10.0);
		where += BPoint(5.0, 5.0);
		menu->Go(where, true, false, mouseRect, true);
	}
}
Esempio n. 2
0
// MouseDown
void
FontValueView::MouseDown(BPoint where)
{
	if (BView* parent = Parent())
		parent->MouseDown(ConvertToParent(where));
	
	if (fProperty) {
		font_family family;
		font_style style;
		fProperty->Value().GetFamilyAndStyle(&family, &style);
		
		BPopUpMenu* menu = new BPopUpMenu("font popup", false, false);
		_PolulateMenu(menu, this, family, style);	

		menu->SetTargetForItems(this);
		menu->SetEnabled(fEnabled);
		
		show_popup_menu(menu, where, this);
	}
}